/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).tf=e.tf||{})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e,t){return e(t={exports:{}},t.exports),t.exports}var r=function(e){return e&&e.Math==Math&&e},a=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||Function("return this")(),i=function(e){try{return!!e()}catch(e){return!0}},o=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),s={}.propertyIsEnumerable,u=Object.getOwnPropertyDescriptor,l={f:u&&!s.call({1:2},1)?function(e){var t=u(this,e);return!!t&&t.enumerable}:s},c=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},p={}.toString,h=function(e){return p.call(e).slice(8,-1)},f="".split,d=i((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==h(e)?f.call(e,""):Object(e)}:Object,m=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},v=function(e){return d(m(e))},g=function(e){return"object"==typeof e?null!==e:"function"==typeof e},y=function(e,t){if(!g(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!g(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!g(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!g(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},b={}.hasOwnProperty,x=function(e,t){return b.call(e,t)},w=a.document,k=g(w)&&g(w.createElement),N=function(e){return k?w.createElement(e):{}},I=!o&&!i((function(){return 7!=Object.defineProperty(N("div"),"a",{get:function(){return 7}}).a})),S=Object.getOwnPropertyDescriptor,T={f:o?S:function(e,t){if(e=v(e),t=y(t,!0),I)try{return S(e,t)}catch(e){}if(x(e,t))return c(!l.f.call(e,t),e[t])}},C=function(e){if(!g(e))throw TypeError(String(e)+" is not an object");return e},E=Object.defineProperty,R={f:o?E:function(e,t,n){if(C(e),t=y(t,!0),C(n),I)try{return E(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},A=o?function(e,t,n){return R.f(e,t,c(1,n))}:function(e,t,n){return e[t]=n,e},D=function(e,t){try{A(a,e,t)}catch(n){a[e]=t}return t},F=a["__core-js_shared__"]||D("__core-js_shared__",{}),_=Function.toString;"function"!=typeof F.inspectSource&&(F.inspectSource=function(e){return _.call(e)});var O,M,L,z=F.inspectSource,P=a.WeakMap,B="function"==typeof P&&/native code/.test(z(P)),W=n((function(e){(e.exports=function(e,t){return F[e]||(F[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),V=0,U=Math.random(),G=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++V+U).toString(36)},j=W("keys"),H=function(e){return j[e]||(j[e]=G(e))},q={},K=a.WeakMap;if(B){var X=new K,Y=X.get,J=X.has,Z=X.set;O=function(e,t){return Z.call(X,e,t),t},M=function(e){return Y.call(X,e)||{}},L=function(e){return J.call(X,e)}}else{var Q=H("state");q[Q]=!0,O=function(e,t){return A(e,Q,t),t},M=function(e){return x(e,Q)?e[Q]:{}},L=function(e){return x(e,Q)}}var $,ee={set:O,get:M,has:L,enforce:function(e){return L(e)?M(e):O(e,{})},getterFor:function(e){return function(t){var n;if(!g(t)||(n=M(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},te=n((function(e){var t=ee.get,n=ee.enforce,r=String(String).split("String");(e.exports=function(e,t,i,o){var s=!!o&&!!o.unsafe,u=!!o&&!!o.enumerable,l=!!o&&!!o.noTargetGet;"function"==typeof i&&("string"!=typeof t||x(i,"name")||A(i,"name",t),n(i).source=r.join("string"==typeof t?t:"")),e!==a?(s?!l&&e[t]&&(u=!0):delete e[t],u?e[t]=i:A(e,t,i)):u?e[t]=i:D(t,i)})(Function.prototype,"toString",(function(){return"function"==typeof this&&t(this).source||z(this)}))})),ne=a,re=function(e){return"function"==typeof e?e:void 0},ae=function(e,t){return arguments.length<2?re(ne[e])||re(a[e]):ne[e]&&ne[e][t]||a[e]&&a[e][t]},ie=Math.ceil,oe=Math.floor,se=function(e){return isNaN(e=+e)?0:(e>0?oe:ie)(e)},ue=Math.min,le=function(e){return e>0?ue(se(e),9007199254740991):0},ce=Math.max,pe=Math.min,he=function(e,t){var n=se(e);return n<0?ce(n+t,0):pe(n,t)},fe=function(e){return function(t,n,r){var a,i=v(t),o=le(i.length),s=he(r,o);if(e&&n!=n){for(;o>s;)if((a=i[s++])!=a)return!0}else for(;o>s;s++)if((e||s in i)&&i[s]===n)return e||s||0;return!e&&-1}},de={includes:fe(!0),indexOf:fe(!1)},me=de.indexOf,ve=function(e,t){var n,r=v(e),a=0,i=[];for(n in r)!x(q,n)&&x(r,n)&&i.push(n);for(;t.length>a;)x(r,n=t[a++])&&(~me(i,n)||i.push(n));return i},ge=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ye=ge.concat("length","prototype"),be={f:Object.getOwnPropertyNames||function(e){return ve(e,ye)}},xe={f:Object.getOwnPropertySymbols},we=ae("Reflect","ownKeys")||function(e){var t=be.f(C(e)),n=xe.f;return n?t.concat(n(e)):t},ke=function(e,t){for(var n=we(t),r=R.f,a=T.f,i=0;i<n.length;i++){var o=n[i];x(e,o)||r(e,o,a(t,o))}},Ne=/#|\.prototype\./,Ie=function(e,t){var n=Te[Se(e)];return n==Ee||n!=Ce&&("function"==typeof t?i(t):!!t)},Se=Ie.normalize=function(e){return String(e).replace(Ne,".").toLowerCase()},Te=Ie.data={},Ce=Ie.NATIVE="N",Ee=Ie.POLYFILL="P",Re=Ie,Ae=T.f,De=function(e,t){var n,r,i,o,s,u=e.target,l=e.global,c=e.stat;if(n=l?a:c?a[u]||D(u,{}):(a[u]||{}).prototype)for(r in t){if(o=t[r],i=e.noTargetGet?(s=Ae(n,r))&&s.value:n[r],!Re(l?r:u+(c?".":"#")+r,e.forced)&&void 0!==i){if(typeof o==typeof i)continue;ke(o,i)}(e.sham||i&&i.sham)&&A(o,"sham",!0),te(n,r,o,e)}},Fe=!!Object.getOwnPropertySymbols&&!i((function(){return!String(Symbol())})),_e=Fe&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Oe=Array.isArray||function(e){return"Array"==h(e)},Me=function(e){return Object(m(e))},Le=Object.keys||function(e){return ve(e,ge)},ze=o?Object.defineProperties:function(e,t){C(e);for(var n,r=Le(t),a=r.length,i=0;a>i;)R.f(e,n=r[i++],t[n]);return e},Pe=ae("document","documentElement"),Be=H("IE_PROTO"),We=function(){},Ve=function(e){return"<script>"+e+"<\/script>"},Ue=function(){try{$=document.domain&&new ActiveXObject("htmlfile")}catch(e){}var e,t;Ue=$?function(e){e.write(Ve("")),e.close();var t=e.parentWindow.Object;return e=null,t}($):((t=N("iframe")).style.display="none",Pe.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Ve("document.F=Object")),e.close(),e.F);for(var n=ge.length;n--;)delete Ue.prototype[ge[n]];return Ue()};q[Be]=!0;var Ge=Object.create||function(e,t){var n;return null!==e?(We.prototype=C(e),n=new We,We.prototype=null,n[Be]=e):n=Ue(),void 0===t?n:ze(n,t)},je=be.f,He={}.toString,qe="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Ke={f:function(e){return qe&&"[object Window]"==He.call(e)?function(e){try{return je(e)}catch(e){return qe.slice()}}(e):je(v(e))}},Xe=W("wks"),Ye=a.Symbol,Je=_e?Ye:Ye&&Ye.withoutSetter||G,Ze=function(e){return x(Xe,e)||(Fe&&x(Ye,e)?Xe[e]=Ye[e]:Xe[e]=Je("Symbol."+e)),Xe[e]},Qe={f:Ze},$e=R.f,et=function(e){var t=ne.Symbol||(ne.Symbol={});x(t,e)||$e(t,e,{value:Qe.f(e)})},tt=R.f,nt=Ze("toStringTag"),rt=function(e,t,n){e&&!x(e=n?e:e.prototype,nt)&&tt(e,nt,{configurable:!0,value:t})},at=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},it=function(e,t,n){if(at(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,a){return e.call(t,n,r,a)}}return function(){return e.apply(t,arguments)}},ot=Ze("species"),st=function(e,t){var n;return Oe(e)&&("function"!=typeof(n=e.constructor)||n!==Array&&!Oe(n.prototype)?g(n)&&null===(n=n[ot])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===t?0:t)},ut=[].push,lt=function(e){var t=1==e,n=2==e,r=3==e,a=4==e,i=6==e,o=5==e||i;return function(s,u,l,c){for(var p,h,f=Me(s),m=d(f),v=it(u,l,3),g=le(m.length),y=0,b=c||st,x=t?b(s,g):n?b(s,0):void 0;g>y;y++)if((o||y in m)&&(h=v(p=m[y],y,f),e))if(t)x[y]=h;else if(h)switch(e){case 3:return!0;case 5:return p;case 6:return y;case 2:ut.call(x,p)}else if(a)return!1;return i?-1:r||a?a:x}},ct={forEach:lt(0),map:lt(1),filter:lt(2),some:lt(3),every:lt(4),find:lt(5),findIndex:lt(6)},pt=ct.forEach,ht=H("hidden"),ft=Ze("toPrimitive"),dt=ee.set,mt=ee.getterFor("Symbol"),vt=Object.prototype,gt=a.Symbol,yt=ae("JSON","stringify"),bt=T.f,xt=R.f,wt=Ke.f,kt=l.f,Nt=W("symbols"),It=W("op-symbols"),St=W("string-to-symbol-registry"),Tt=W("symbol-to-string-registry"),Ct=W("wks"),Et=a.QObject,Rt=!Et||!Et.prototype||!Et.prototype.findChild,At=o&&i((function(){return 7!=Ge(xt({},"a",{get:function(){return xt(this,"a",{value:7}).a}})).a}))?function(e,t,n){var r=bt(vt,t);r&&delete vt[t],xt(e,t,n),r&&e!==vt&&xt(vt,t,r)}:xt,Dt=function(e,t){var n=Nt[e]=Ge(gt.prototype);return dt(n,{type:"Symbol",tag:e,description:t}),o||(n.description=t),n},Ft=_e?function(e){return"symbol"==typeof e}:function(e){return Object(e)instanceof gt},_t=function(e,t,n){e===vt&&_t(It,t,n),C(e);var r=y(t,!0);return C(n),x(Nt,r)?(n.enumerable?(x(e,ht)&&e[ht][r]&&(e[ht][r]=!1),n=Ge(n,{enumerable:c(0,!1)})):(x(e,ht)||xt(e,ht,c(1,{})),e[ht][r]=!0),At(e,r,n)):xt(e,r,n)},Ot=function(e,t){C(e);var n=v(t),r=Le(n).concat(Pt(n));return pt(r,(function(t){o&&!Mt.call(n,t)||_t(e,t,n[t])})),e},Mt=function(e){var t=y(e,!0),n=kt.call(this,t);return!(this===vt&&x(Nt,t)&&!x(It,t))&&(!(n||!x(this,t)||!x(Nt,t)||x(this,ht)&&this[ht][t])||n)},Lt=function(e,t){var n=v(e),r=y(t,!0);if(n!==vt||!x(Nt,r)||x(It,r)){var a=bt(n,r);return!a||!x(Nt,r)||x(n,ht)&&n[ht][r]||(a.enumerable=!0),a}},zt=function(e){var t=wt(v(e)),n=[];return pt(t,(function(e){x(Nt,e)||x(q,e)||n.push(e)})),n},Pt=function(e){var t=e===vt,n=wt(t?It:v(e)),r=[];return pt(n,(function(e){!x(Nt,e)||t&&!x(vt,e)||r.push(Nt[e])})),r};if(Fe||(te((gt=function(){if(this instanceof gt)throw TypeError("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?String(arguments[0]):void 0,t=G(e),n=function e(n){this===vt&&e.call(It,n),x(this,ht)&&x(this[ht],t)&&(this[ht][t]=!1),At(this,t,c(1,n))};return o&&Rt&&At(vt,t,{configurable:!0,set:n}),Dt(t,e)}).prototype,"toString",(function(){return mt(this).tag})),te(gt,"withoutSetter",(function(e){return Dt(G(e),e)})),l.f=Mt,R.f=_t,T.f=Lt,be.f=Ke.f=zt,xe.f=Pt,Qe.f=function(e){return Dt(Ze(e),e)},o&&(xt(gt.prototype,"description",{configurable:!0,get:function(){return mt(this).description}}),te(vt,"propertyIsEnumerable",Mt,{unsafe:!0}))),De({global:!0,wrap:!0,forced:!Fe,sham:!Fe},{Symbol:gt}),pt(Le(Ct),(function(e){et(e)})),De({target:"Symbol",stat:!0,forced:!Fe},{for:function(e){var t=String(e);if(x(St,t))return St[t];var n=gt(t);return St[t]=n,Tt[n]=t,n},keyFor:function(e){if(!Ft(e))throw TypeError(e+" is not a symbol");if(x(Tt,e))return Tt[e]},useSetter:function(){Rt=!0},useSimple:function(){Rt=!1}}),De({target:"Object",stat:!0,forced:!Fe,sham:!o},{create:function(e,t){return void 0===t?Ge(e):Ot(Ge(e),t)},defineProperty:_t,defineProperties:Ot,getOwnPropertyDescriptor:Lt}),De({target:"Object",stat:!0,forced:!Fe},{getOwnPropertyNames:zt,getOwnPropertySymbols:Pt}),De({target:"Object",stat:!0,forced:i((function(){xe.f(1)}))},{getOwnPropertySymbols:function(e){return xe.f(Me(e))}}),yt){var Bt=!Fe||i((function(){var e=gt();return"[null]"!=yt([e])||"{}"!=yt({a:e})||"{}"!=yt(Object(e))}));De({target:"JSON",stat:!0,forced:Bt},{stringify:function(e,t,n){for(var r,a=[e],i=1;arguments.length>i;)a.push(arguments[i++]);if(r=t,(g(t)||void 0!==e)&&!Ft(e))return Oe(t)||(t=function(e,t){if("function"==typeof r&&(t=r.call(this,e,t)),!Ft(t))return t}),a[1]=t,yt.apply(null,a)}})}gt.prototype[ft]||A(gt.prototype,ft,gt.prototype.valueOf),rt(gt,"Symbol"),q[ht]=!0,et("asyncIterator");var Wt=R.f,Vt=a.Symbol;if(o&&"function"==typeof Vt&&(!("description"in Vt.prototype)||void 0!==Vt().description)){var Ut={},Gt=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),t=this instanceof Gt?new Vt(e):void 0===e?Vt():Vt(e);return""===e&&(Ut[t]=!0),t};ke(Gt,Vt);var jt=Gt.prototype=Vt.prototype;jt.constructor=Gt;var Ht=jt.toString,qt="Symbol(test)"==String(Vt("test")),Kt=/^Symbol\((.*)\)[^)]+$/;Wt(jt,"description",{configurable:!0,get:function(){var e=g(this)?this.valueOf():this,t=Ht.call(e);if(x(Ut,e))return"";var n=qt?t.slice(7,-1):t.replace(Kt,"$1");return""===n?void 0:n}}),De({global:!0,forced:!0},{Symbol:Gt})}et("hasInstance"),et("isConcatSpreadable"),et("iterator"),et("match"),et("matchAll"),et("replace"),et("search"),et("species"),et("split"),et("toPrimitive"),et("toStringTag"),et("unscopables");var Xt=Object.assign,Yt=Object.defineProperty,Jt=!Xt||i((function(){if(o&&1!==Xt({b:1},Xt(Yt({},"a",{enumerable:!0,get:function(){Yt(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol();return e[n]=7,"abcdefghijklmnopqrst".split("").forEach((function(e){t[e]=e})),7!=Xt({},e)[n]||"abcdefghijklmnopqrst"!=Le(Xt({},t)).join("")}))?function(e,t){for(var n=Me(e),r=arguments.length,a=1,i=xe.f,s=l.f;r>a;)for(var u,c=d(arguments[a++]),p=i?Le(c).concat(i(c)):Le(c),h=p.length,f=0;h>f;)u=p[f++],o&&!s.call(c,u)||(n[u]=c[u]);return n}:Xt;De({target:"Object",stat:!0,forced:Object.assign!==Jt},{assign:Jt}),De({target:"Object",stat:!0,sham:!o},{create:Ge}),De({target:"Object",stat:!0,forced:!o,sham:!o},{defineProperty:R.f}),De({target:"Object",stat:!0,forced:!o,sham:!o},{defineProperties:ze});var Zt=l.f,Qt=function(e){return function(t){for(var n,r=v(t),a=Le(r),i=a.length,s=0,u=[];i>s;)n=a[s++],o&&!Zt.call(r,n)||u.push(e?[n,r[n]]:r[n]);return u}},$t={entries:Qt(!0),values:Qt(!1)},en=$t.entries;De({target:"Object",stat:!0},{entries:function(e){return en(e)}});var tn=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),nn=n((function(e){var t=R.f,n=G("meta"),r=0,a=Object.isExtensible||function(){return!0},i=function(e){t(e,n,{value:{objectID:"O"+ ++r,weakData:{}}})},o=e.exports={REQUIRED:!1,fastKey:function(e,t){if(!g(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!x(e,n)){if(!a(e))return"F";if(!t)return"E";i(e)}return e[n].objectID},getWeakData:function(e,t){if(!x(e,n)){if(!a(e))return!0;if(!t)return!1;i(e)}return e[n].weakData},onFreeze:function(e){return tn&&o.REQUIRED&&a(e)&&!x(e,n)&&i(e),e}};q[n]=!0})),rn=(nn.REQUIRED,nn.fastKey,nn.getWeakData,nn.onFreeze,nn.onFreeze),an=Object.freeze,on=i((function(){an(1)}));De({target:"Object",stat:!0,forced:on,sham:!tn},{freeze:function(e){return an&&g(e)?an(rn(e)):e}});var sn={},un=Ze("iterator"),ln=Array.prototype,cn=function(e){return void 0!==e&&(sn.Array===e||ln[un]===e)},pn={};pn[Ze("toStringTag")]="z";var hn="[object z]"===String(pn),fn=Ze("toStringTag"),dn="Arguments"==h(function(){return arguments}()),mn=hn?h:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),fn))?n:dn?h(t):"Object"==(r=h(t))&&"function"==typeof t.callee?"Arguments":r},vn=Ze("iterator"),gn=function(e){if(null!=e)return e[vn]||e["@@iterator"]||sn[mn(e)]},yn=function(e,t,n,r){try{return r?t(C(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw void 0!==a&&C(a.call(e)),t}},bn=n((function(e){var t=function(e,t){this.stopped=e,this.result=t};(e.exports=function(e,n,r,a,i){var o,s,u,l,c,p,h,f=it(n,r,a?2:1);if(i)o=e;else{if("function"!=typeof(s=gn(e)))throw TypeError("Target is not iterable");if(cn(s)){for(u=0,l=le(e.length);l>u;u++)if((c=a?f(C(h=e[u])[0],h[1]):f(e[u]))&&c instanceof t)return c;return new t(!1)}o=s.call(e)}for(p=o.next;!(h=p.call(o)).done;)if("object"==typeof(c=yn(o,f,h.value,a))&&c&&c instanceof t)return c;return new t(!1)}).stop=function(e){return new t(!0,e)}})),xn=function(e,t,n){var r=y(t);r in e?R.f(e,r,c(0,n)):e[r]=n};De({target:"Object",stat:!0},{fromEntries:function(e){var t={};return bn(e,(function(e,n){xn(t,e,n)}),void 0,!0),t}});var wn=T.f,kn=i((function(){wn(1)}));De({target:"Object",stat:!0,forced:!o||kn,sham:!o},{getOwnPropertyDescriptor:function(e,t){return wn(v(e),t)}}),De({target:"Object",stat:!0,sham:!o},{getOwnPropertyDescriptors:function(e){for(var t,n,r=v(e),a=T.f,i=we(r),o={},s=0;i.length>s;)void 0!==(n=a(r,t=i[s++]))&&xn(o,t,n);return o}});var Nn=Ke.f,In=i((function(){return!Object.getOwnPropertyNames(1)}));De({target:"Object",stat:!0,forced:In},{getOwnPropertyNames:Nn});var Sn=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Tn=H("IE_PROTO"),Cn=Object.prototype,En=Sn?Object.getPrototypeOf:function(e){return e=Me(e),x(e,Tn)?e[Tn]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?Cn:null},Rn=i((function(){En(1)}));De({target:"Object",stat:!0,forced:Rn,sham:!Sn},{getPrototypeOf:function(e){return En(Me(e))}});var An=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t};De({target:"Object",stat:!0},{is:An});var Dn=Object.isExtensible,Fn=i((function(){Dn(1)}));De({target:"Object",stat:!0,forced:Fn},{isExtensible:function(e){return!!g(e)&&(!Dn||Dn(e))}});var _n=Object.isFrozen,On=i((function(){_n(1)}));De({target:"Object",stat:!0,forced:On},{isFrozen:function(e){return!g(e)||!!_n&&_n(e)}});var Mn=Object.isSealed,Ln=i((function(){Mn(1)}));De({target:"Object",stat:!0,forced:Ln},{isSealed:function(e){return!g(e)||!!Mn&&Mn(e)}});var zn=i((function(){Le(1)}));De({target:"Object",stat:!0,forced:zn},{keys:function(e){return Le(Me(e))}});var Pn=nn.onFreeze,Bn=Object.preventExtensions,Wn=i((function(){Bn(1)}));De({target:"Object",stat:!0,forced:Wn,sham:!tn},{preventExtensions:function(e){return Bn&&g(e)?Bn(Pn(e)):e}});var Vn=nn.onFreeze,Un=Object.seal,Gn=i((function(){Un(1)}));De({target:"Object",stat:!0,forced:Gn,sham:!tn},{seal:function(e){return Un&&g(e)?Un(Vn(e)):e}});var jn=function(e){if(!g(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype");return e},Hn=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),t=n instanceof Array}catch(e){}return function(n,r){return C(n),jn(r),t?e.call(n,r):n.__proto__=r,n}}():void 0);De({target:"Object",stat:!0},{setPrototypeOf:Hn});var qn=$t.values;De({target:"Object",stat:!0},{values:function(e){return qn(e)}});var Kn=hn?{}.toString:function(){return"[object "+mn(this)+"]"};hn||te(Object.prototype,"toString",Kn,{unsafe:!0});var Xn=!i((function(){var e=Math.random();__defineSetter__.call(null,e,(function(){})),delete a[e]}));o&&De({target:"Object",proto:!0,forced:Xn},{__defineGetter__:function(e,t){R.f(Me(this),e,{get:at(t),enumerable:!0,configurable:!0})}}),o&&De({target:"Object",proto:!0,forced:Xn},{__defineSetter__:function(e,t){R.f(Me(this),e,{set:at(t),enumerable:!0,configurable:!0})}});var Yn=T.f;o&&De({target:"Object",proto:!0,forced:Xn},{__lookupGetter__:function(e){var t,n=Me(this),r=y(e,!0);do{if(t=Yn(n,r))return t.get}while(n=En(n))}});var Jn=T.f;o&&De({target:"Object",proto:!0,forced:Xn},{__lookupSetter__:function(e){var t,n=Me(this),r=y(e,!0);do{if(t=Jn(n,r))return t.set}while(n=En(n))}});var Zn=[].slice,Qn={},$n=function(e,t,n){if(!(t in Qn)){for(var r=[],a=0;a<t;a++)r[a]="a["+a+"]";Qn[t]=Function("C,a","return new C("+r.join(",")+")")}return Qn[t](e,n)},er=Function.bind||function(e){var t=at(this),n=Zn.call(arguments,1),r=function(){var a=n.concat(Zn.call(arguments));return this instanceof r?$n(t,a.length,a):t.apply(e,a)};return g(t.prototype)&&(r.prototype=t.prototype),r};De({target:"Function",proto:!0},{bind:er});var tr=R.f,nr=Function.prototype,rr=nr.toString,ar=/^\s*function ([^ (]*)/;o&&!("name"in nr)&&tr(nr,"name",{configurable:!0,get:function(){try{return rr.call(this).match(ar)[1]}catch(e){return""}}});var ir=Ze("hasInstance"),or=Function.prototype;ir in or||R.f(or,ir,{value:function(e){if("function"!=typeof this||!g(e))return!1;if(!g(this.prototype))return e instanceof this;for(;e=En(e);)if(this.prototype===e)return!0;return!1}}),De({global:!0},{globalThis:a});var sr=function(e){var t,n,r,a,i,o,s=Me(e),u="function"==typeof this?this:Array,l=arguments.length,c=l>1?arguments[1]:void 0,p=void 0!==c,h=gn(s),f=0;if(p&&(c=it(c,l>2?arguments[2]:void 0,2)),null==h||u==Array&&cn(h))for(n=new u(t=le(s.length));t>f;f++)o=p?c(s[f],f):s[f],xn(n,f,o);else for(i=(a=h.call(s)).next,n=new u;!(r=i.call(a)).done;f++)o=p?yn(a,c,[r.value,f],!0):r.value,xn(n,f,o);return n.length=f,n},ur=Ze("iterator"),lr=!1;try{var cr=0,pr={next:function(){return{done:!!cr++}},return:function(){lr=!0}};pr[ur]=function(){return this},Array.from(pr,(function(){throw 2}))}catch(e){}var hr=function(e,t){if(!t&&!lr)return!1;var n=!1;try{var r={};r[ur]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},fr=!hr((function(e){Array.from(e)}));De({target:"Array",stat:!0,forced:fr},{from:sr}),De({target:"Array",stat:!0},{isArray:Oe});var dr=i((function(){function e(){}return!(Array.of.call(e)instanceof e)}));De({target:"Array",stat:!0,forced:dr},{of:function(){for(var e=0,t=arguments.length,n=new("function"==typeof this?this:Array)(t);t>e;)xn(n,e,arguments[e++]);return n.length=t,n}});var mr,vr,gr=ae("navigator","userAgent")||"",yr=a.process,br=yr&&yr.versions,xr=br&&br.v8;xr?vr=(mr=xr.split("."))[0]+mr[1]:gr&&(!(mr=gr.match(/Edge\/(\d+)/))||mr[1]>=74)&&(mr=gr.match(/Chrome\/(\d+)/))&&(vr=mr[1]);var wr=vr&&+vr,kr=Ze("species"),Nr=function(e){return wr>=51||!i((function(){var t=[];return(t.constructor={})[kr]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Ir=Ze("isConcatSpreadable"),Sr=wr>=51||!i((function(){var e=[];return e[Ir]=!1,e.concat()[0]!==e})),Tr=Nr("concat"),Cr=function(e){if(!g(e))return!1;var t=e[Ir];return void 0!==t?!!t:Oe(e)};De({target:"Array",proto:!0,forced:!Sr||!Tr},{concat:function(e){var t,n,r,a,i,o=Me(this),s=st(o,0),u=0;for(t=-1,r=arguments.length;t<r;t++)if(i=-1===t?o:arguments[t],Cr(i)){if(u+(a=le(i.length))>9007199254740991)throw TypeError("Maximum allowed index exceeded");for(n=0;n<a;n++,u++)n in i&&xn(s,u,i[n])}else{if(u>=9007199254740991)throw TypeError("Maximum allowed index exceeded");xn(s,u++,i)}return s.length=u,s}});var Er=Math.min,Rr=[].copyWithin||function(e,t){var n=Me(this),r=le(n.length),a=he(e,r),i=he(t,r),o=arguments.length>2?arguments[2]:void 0,s=Er((void 0===o?r:he(o,r))-i,r-a),u=1;for(i<a&&a<i+s&&(u=-1,i+=s-1,a+=s-1);s-- >0;)i in n?n[a]=n[i]:delete n[a],a+=u,i+=u;return n},Ar=Ze("unscopables"),Dr=Array.prototype;null==Dr[Ar]&&R.f(Dr,Ar,{configurable:!0,value:Ge(null)});var Fr=function(e){Dr[Ar][e]=!0};De({target:"Array",proto:!0},{copyWithin:Rr}),Fr("copyWithin");var _r=function(e,t){var n=[][e];return!!n&&i((function(){n.call(null,t||function(){throw 1},1)}))},Or=Object.defineProperty,Mr={},Lr=function(e){throw e},zr=function(e,t){if(x(Mr,e))return Mr[e];t||(t={});var n=[][e],r=!!x(t,"ACCESSORS")&&t.ACCESSORS,a=x(t,0)?t[0]:Lr,s=x(t,1)?t[1]:void 0;return Mr[e]=!!n&&!i((function(){if(r&&!o)return!0;var e={length:-1};r?Or(e,1,{enumerable:!0,get:Lr}):e[1]=1,n.call(e,a,s)}))},Pr=ct.every,Br=_r("every"),Wr=zr("every");De({target:"Array",proto:!0,forced:!Br||!Wr},{every:function(e){return Pr(this,e,arguments.length>1?arguments[1]:void 0)}});var Vr=function(e){for(var t=Me(this),n=le(t.length),r=arguments.length,a=he(r>1?arguments[1]:void 0,n),i=r>2?arguments[2]:void 0,o=void 0===i?n:he(i,n);o>a;)t[a++]=e;return t};De({target:"Array",proto:!0},{fill:Vr}),Fr("fill");var Ur=ct.filter,Gr=Nr("filter"),jr=zr("filter");De({target:"Array",proto:!0,forced:!Gr||!jr},{filter:function(e){return Ur(this,e,arguments.length>1?arguments[1]:void 0)}});var Hr=ct.find,qr=!0,Kr=zr("find");"find"in[]&&Array(1).find((function(){qr=!1})),De({target:"Array",proto:!0,forced:qr||!Kr},{find:function(e){return Hr(this,e,arguments.length>1?arguments[1]:void 0)}}),Fr("find");var Xr=ct.findIndex,Yr=!0,Jr=zr("findIndex");"findIndex"in[]&&Array(1).findIndex((function(){Yr=!1})),De({target:"Array",proto:!0,forced:Yr||!Jr},{findIndex:function(e){return Xr(this,e,arguments.length>1?arguments[1]:void 0)}}),Fr("findIndex");var Zr=function e(t,n,r,a,i,o,s,u){for(var l,c=i,p=0,h=!!s&&it(s,u,3);p<a;){if(p in r){if(l=h?h(r[p],p,n):r[p],o>0&&Oe(l))c=e(t,n,l,le(l.length),c,o-1)-1;else{if(c>=9007199254740991)throw TypeError("Exceed the acceptable array length");t[c]=l}c++}p++}return c};De({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Me(this),n=le(t.length),r=st(t,0);return r.length=Zr(r,t,t,n,0,void 0===e?1:se(e)),r}}),De({target:"Array",proto:!0},{flatMap:function(e){var t,n=Me(this),r=le(n.length);return at(e),(t=st(n,0)).length=Zr(t,n,n,r,0,1,e,arguments.length>1?arguments[1]:void 0),t}});var Qr=ct.forEach,$r=_r("forEach"),ea=zr("forEach"),ta=$r&&ea?[].forEach:function(e){return Qr(this,e,arguments.length>1?arguments[1]:void 0)};De({target:"Array",proto:!0,forced:[].forEach!=ta},{forEach:ta});var na=de.includes,ra=zr("indexOf",{ACCESSORS:!0,1:0});De({target:"Array",proto:!0,forced:!ra},{includes:function(e){return na(this,e,arguments.length>1?arguments[1]:void 0)}}),Fr("includes");var aa=de.indexOf,ia=[].indexOf,oa=!!ia&&1/[1].indexOf(1,-0)<0,sa=_r("indexOf"),ua=zr("indexOf",{ACCESSORS:!0,1:0});De({target:"Array",proto:!0,forced:oa||!sa||!ua},{indexOf:function(e){return oa?ia.apply(this,arguments)||0:aa(this,e,arguments.length>1?arguments[1]:void 0)}});var la=[].join,ca=d!=Object,pa=_r("join",",");De({target:"Array",proto:!0,forced:ca||!pa},{join:function(e){return la.call(v(this),void 0===e?",":e)}});var ha=Math.min,fa=[].lastIndexOf,da=!!fa&&1/[1].lastIndexOf(1,-0)<0,ma=_r("lastIndexOf"),va=zr("indexOf",{ACCESSORS:!0,1:0}),ga=da||!ma||!va?function(e){if(da)return fa.apply(this,arguments)||0;var t=v(this),n=le(t.length),r=n-1;for(arguments.length>1&&(r=ha(r,se(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:fa;De({target:"Array",proto:!0,forced:ga!==[].lastIndexOf},{lastIndexOf:ga});var ya=ct.map,ba=Nr("map"),xa=zr("map");De({target:"Array",proto:!0,forced:!ba||!xa},{map:function(e){return ya(this,e,arguments.length>1?arguments[1]:void 0)}});var wa=function(e){return function(t,n,r,a){at(n);var i=Me(t),o=d(i),s=le(i.length),u=e?s-1:0,l=e?-1:1;if(r<2)for(;;){if(u in o){a=o[u],u+=l;break}if(u+=l,e?u<0:s<=u)throw TypeError("Reduce of empty array with no initial value")}for(;e?u>=0:s>u;u+=l)u in o&&(a=n(a,o[u],u,i));return a}},ka={left:wa(!1),right:wa(!0)},Na=ka.left,Ia=_r("reduce"),Sa=zr("reduce",{1:0});De({target:"Array",proto:!0,forced:!Ia||!Sa},{reduce:function(e){return Na(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var Ta=ka.right,Ca=_r("reduceRight"),Ea=zr("reduce",{1:0});De({target:"Array",proto:!0,forced:!Ca||!Ea},{reduceRight:function(e){return Ta(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var Ra=[].reverse,Aa=[1,2];De({target:"Array",proto:!0,forced:String(Aa)===String(Aa.reverse())},{reverse:function(){return Oe(this)&&(this.length=this.length),Ra.call(this)}});var Da=Nr("slice"),Fa=zr("slice",{ACCESSORS:!0,0:0,1:2}),_a=Ze("species"),Oa=[].slice,Ma=Math.max;De({target:"Array",proto:!0,forced:!Da||!Fa},{slice:function(e,t){var n,r,a,i=v(this),o=le(i.length),s=he(e,o),u=he(void 0===t?o:t,o);if(Oe(i)&&("function"!=typeof(n=i.constructor)||n!==Array&&!Oe(n.prototype)?g(n)&&null===(n=n[_a])&&(n=void 0):n=void 0,n===Array||void 0===n))return Oa.call(i,s,u);for(r=new(void 0===n?Array:n)(Ma(u-s,0)),a=0;s<u;s++,a++)s in i&&xn(r,a,i[s]);return r.length=a,r}});var La=ct.some,za=_r("some"),Pa=zr("some");De({target:"Array",proto:!0,forced:!za||!Pa},{some:function(e){return La(this,e,arguments.length>1?arguments[1]:void 0)}});var Ba=[],Wa=Ba.sort,Va=i((function(){Ba.sort(void 0)})),Ua=i((function(){Ba.sort(null)})),Ga=_r("sort");De({target:"Array",proto:!0,forced:Va||!Ua||!Ga},{sort:function(e){return void 0===e?Wa.call(Me(this)):Wa.call(Me(this),at(e))}});var ja=Nr("splice"),Ha=zr("splice",{ACCESSORS:!0,0:0,1:2}),qa=Math.max,Ka=Math.min;De({target:"Array",proto:!0,forced:!ja||!Ha},{splice:function(e,t){var n,r,a,i,o,s,u=Me(this),l=le(u.length),c=he(e,l),p=arguments.length;if(0===p?n=r=0:1===p?(n=0,r=l-c):(n=p-2,r=Ka(qa(se(t),0),l-c)),l+n-r>9007199254740991)throw TypeError("Maximum allowed length exceeded");for(a=st(u,r),i=0;i<r;i++)(o=c+i)in u&&xn(a,i,u[o]);if(a.length=r,n<r){for(i=c;i<l-r;i++)s=i+n,(o=i+r)in u?u[s]=u[o]:delete u[s];for(i=l;i>l-r+n;i--)delete u[i-1]}else if(n>r)for(i=l-r;i>c;i--)s=i+n-1,(o=i+r-1)in u?u[s]=u[o]:delete u[s];for(i=0;i<n;i++)u[i+c]=arguments[i+2];return u.length=l-r+n,a}});var Xa=Ze("species"),Ya=function(e){var t=ae(e),n=R.f;o&&t&&!t[Xa]&&n(t,Xa,{configurable:!0,get:function(){return this}})};Ya("Array"),Fr("flat"),Fr("flatMap");var Ja,Za,Qa,$a=Ze("iterator"),ei=!1;[].keys&&("next"in(Qa=[].keys())?(Za=En(En(Qa)))!==Object.prototype&&(Ja=Za):ei=!0),null==Ja&&(Ja={}),x(Ja,$a)||A(Ja,$a,(function(){return this}));var ti={IteratorPrototype:Ja,BUGGY_SAFARI_ITERATORS:ei},ni=ti.IteratorPrototype,ri=function(){return this},ai=function(e,t,n){var r=t+" Iterator";return e.prototype=Ge(ni,{next:c(1,n)}),rt(e,r,!1),sn[r]=ri,e},ii=ti.IteratorPrototype,oi=ti.BUGGY_SAFARI_ITERATORS,si=Ze("iterator"),ui=function(){return this},li=function(e,t,n,r,a,i,o){ai(n,t,r);var s,u,l,c=function(e){if(e===a&&m)return m;if(!oi&&e in f)return f[e];switch(e){case"keys":case"values":case"entries":return function(){return new n(this,e)}}return function(){return new n(this)}},p=t+" Iterator",h=!1,f=e.prototype,d=f[si]||f["@@iterator"]||a&&f[a],m=!oi&&d||c(a),v="Array"==t&&f.entries||d;if(v&&(s=En(v.call(new e)),ii!==Object.prototype&&s.next&&(En(s)!==ii&&(Hn?Hn(s,ii):"function"!=typeof s[si]&&A(s,si,ui)),rt(s,p,!0))),"values"==a&&d&&"values"!==d.name&&(h=!0,m=function(){return d.call(this)}),f[si]!==m&&A(f,si,m),sn[t]=m,a)if(u={values:c("values"),keys:i?m:c("keys"),entries:c("entries")},o)for(l in u)(oi||h||!(l in f))&&te(f,l,u[l]);else De({target:t,proto:!0,forced:oi||h},u);return u},ci=ee.set,pi=ee.getterFor("Array Iterator"),hi=li(Array,"Array",(function(e,t){ci(this,{type:"Array Iterator",target:v(e),index:0,kind:t})}),(function(){var e=pi(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}}),"values");sn.Arguments=sn.Array,Fr("keys"),Fr("values"),Fr("entries");var fi=String.fromCharCode,di=String.fromCodePoint,mi=!!di&&1!=di.length;De({target:"String",stat:!0,forced:mi},{fromCodePoint:function(e){for(var t,n=[],r=arguments.length,a=0;r>a;){if(t=+arguments[a++],he(t,1114111)!==t)throw RangeError(t+" is not a valid code point");n.push(t<65536?fi(t):fi(55296+((t-=65536)>>10),t%1024+56320))}return n.join("")}}),De({target:"String",stat:!0},{raw:function(e){for(var t=v(e.raw),n=le(t.length),r=arguments.length,a=[],i=0;n>i;)a.push(String(t[i++])),i<r&&a.push(String(arguments[i]));return a.join("")}});var vi=function(e){return function(t,n){var r,a,i=String(m(t)),o=se(n),s=i.length;return o<0||o>=s?e?"":void 0:(r=i.charCodeAt(o))<55296||r>56319||o+1===s||(a=i.charCodeAt(o+1))<56320||a>57343?e?i.charAt(o):r:e?i.slice(o,o+2):a-56320+(r-55296<<10)+65536}},gi={codeAt:vi(!1),charAt:vi(!0)},yi=gi.codeAt;De({target:"String",proto:!0},{codePointAt:function(e){return yi(this,e)}});var bi,xi=Ze("match"),wi=function(e){var t;return g(e)&&(void 0!==(t=e[xi])?!!t:"RegExp"==h(e))},ki=function(e){if(wi(e))throw TypeError("The method doesn't accept regular expressions");return e},Ni=Ze("match"),Ii=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[Ni]=!1,"/./"[e](t)}catch(e){}}return!1},Si=T.f,Ti="".endsWith,Ci=Math.min,Ei=Ii("endsWith"),Ri=!(Ei||(bi=Si(String.prototype,"endsWith"),!bi||bi.writable));De({target:"String",proto:!0,forced:!Ri&&!Ei},{endsWith:function(e){var t=String(m(this));ki(e);var n=arguments.length>1?arguments[1]:void 0,r=le(t.length),a=void 0===n?r:Ci(le(n),r),i=String(e);return Ti?Ti.call(t,i,a):t.slice(a-i.length,a)===i}}),De({target:"String",proto:!0,forced:!Ii("includes")},{includes:function(e){return!!~String(m(this)).indexOf(ki(e),arguments.length>1?arguments[1]:void 0)}});var Ai=function(){var e=C(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t};function Di(e,t){return RegExp(e,t)}var Fi={UNSUPPORTED_Y:i((function(){var e=Di("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),BROKEN_CARET:i((function(){var e=Di("^r","gy");return e.lastIndex=2,null!=e.exec("str")}))},_i=RegExp.prototype.exec,Oi=String.prototype.replace,Mi=_i,Li=function(){var e=/a/,t=/b*/g;return _i.call(e,"a"),_i.call(t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),zi=Fi.UNSUPPORTED_Y||Fi.BROKEN_CARET,Pi=void 0!==/()??/.exec("")[1];(Li||Pi||zi)&&(Mi=function(e){var t,n,r,a,i=this,o=zi&&i.sticky,s=Ai.call(i),u=i.source,l=0,c=e;return o&&(-1===(s=s.replace("y","")).indexOf("g")&&(s+="g"),c=String(e).slice(i.lastIndex),i.lastIndex>0&&(!i.multiline||i.multiline&&"\n"!==e[i.lastIndex-1])&&(u="(?: "+u+")",c=" "+c,l++),n=new RegExp("^(?:"+u+")",s)),Pi&&(n=new RegExp("^"+u+"$(?!\\s)",s)),Li&&(t=i.lastIndex),r=_i.call(o?n:i,c),o?r?(r.input=r.input.slice(l),r[0]=r[0].slice(l),r.index=i.lastIndex,i.lastIndex+=r[0].length):i.lastIndex=0:Li&&r&&(i.lastIndex=i.global?r.index+r[0].length:t),Pi&&r&&r.length>1&&Oi.call(r[0],n,(function(){for(a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(r[a]=void 0)})),r});var Bi=Mi;De({target:"RegExp",proto:!0,forced:/./.exec!==Bi},{exec:Bi});var Wi=Ze("species"),Vi=!i((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")})),Ui="$0"==="a".replace(/./,"$0"),Gi=Ze("replace"),ji=!!/./[Gi]&&""===/./[Gi]("a","$0"),Hi=!i((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]})),qi=function(e,t,n,r){var a=Ze(e),o=!i((function(){var t={};return t[a]=function(){return 7},7!=""[e](t)})),s=o&&!i((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[Wi]=function(){return n},n.flags="",n[a]=/./[a]),n.exec=function(){return t=!0,null},n[a](""),!t}));if(!o||!s||"replace"===e&&(!Vi||!Ui||ji)||"split"===e&&!Hi){var u=/./[a],l=n(a,""[e],(function(e,t,n,r,a){return t.exec===Bi?o&&!a?{done:!0,value:u.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}),{REPLACE_KEEPS_$0:Ui,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:ji}),c=l[0],p=l[1];te(String.prototype,e,c),te(RegExp.prototype,a,2==t?function(e,t){return p.call(e,this,t)}:function(e){return p.call(e,this)})}r&&A(RegExp.prototype[a],"sham",!0)},Ki=gi.charAt,Xi=function(e,t,n){return t+(n?Ki(e,t).length:1)},Yi=function(e,t){var n=e.exec;if("function"==typeof n){var r=n.call(e,t);if("object"!=typeof r)throw TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==h(e))throw TypeError("RegExp#exec called on incompatible receiver");return Bi.call(e,t)};qi("match",1,(function(e,t,n){return[function(t){var n=m(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](String(n))},function(e){var r=n(t,e,this);if(r.done)return r.value;var a=C(e),i=String(this);if(!a.global)return Yi(a,i);var o=a.unicode;a.lastIndex=0;for(var s,u=[],l=0;null!==(s=Yi(a,i));){var c=String(s[0]);u[l]=c,""===c&&(a.lastIndex=Xi(i,le(a.lastIndex),o)),l++}return 0===l?null:u}]}));var Ji=Ze("species"),Zi=function(e,t){var n,r=C(e).constructor;return void 0===r||null==(n=C(r)[Ji])?t:at(n)},Qi=Ze("matchAll"),$i=ee.set,eo=ee.getterFor("RegExp String Iterator"),to=RegExp.prototype,no=to.exec,ro="".matchAll,ao=!!ro&&!i((function(){"a".matchAll(/./)})),io=ai((function(e,t,n,r){$i(this,{type:"RegExp String Iterator",regexp:e,string:t,global:n,unicode:r,done:!1})}),"RegExp String",(function(){var e=eo(this);if(e.done)return{value:void 0,done:!0};var t=e.regexp,n=e.string,r=function(e,t){var n,r=e.exec;if("function"==typeof r){if("object"!=typeof(n=r.call(e,t)))throw TypeError("Incorrect exec result");return n}return no.call(e,t)}(t,n);return null===r?{value:void 0,done:e.done=!0}:e.global?(""==String(r[0])&&(t.lastIndex=Xi(n,le(t.lastIndex),e.unicode)),{value:r,done:!1}):(e.done=!0,{value:r,done:!1})})),oo=function(e){var t,n,r,a,i,o,s=C(this),u=String(e);return t=Zi(s,RegExp),void 0===(n=s.flags)&&s instanceof RegExp&&!("flags"in to)&&(n=Ai.call(s)),r=void 0===n?"":String(n),a=new t(t===RegExp?s.source:s,r),i=!!~r.indexOf("g"),o=!!~r.indexOf("u"),a.lastIndex=le(s.lastIndex),new io(a,u,i,o)};De({target:"String",proto:!0,forced:ao},{matchAll:function(e){var t,n,r=m(this);if(null!=e){if(wi(e)&&!~String(m("flags"in to?e.flags:Ai.call(e))).indexOf("g"))throw TypeError("`.matchAll` does not allow non-global regexes");if(ao)return ro.apply(r,arguments);if(null!=(n=e[Qi]))return at(n).call(e,r)}else if(ao)return ro.apply(r,arguments);return t=String(r),new RegExp(e,"g")[Qi](t)}}),Qi in to||A(to,Qi,oo);var so="".repeat||function(e){var t=String(m(this)),n="",r=se(e);if(r<0||r==1/0)throw RangeError("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n},uo=Math.ceil,lo=function(e){return function(t,n,r){var a,i,o=String(m(t)),s=o.length,u=void 0===r?" ":String(r),l=le(n);return l<=s||""==u?o:(a=l-s,(i=so.call(u,uo(a/u.length))).length>a&&(i=i.slice(0,a)),e?o+i:i+o)}},co={start:lo(!1),end:lo(!0)},po=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(gr),ho=co.end;De({target:"String",proto:!0,forced:po},{padEnd:function(e){return ho(this,e,arguments.length>1?arguments[1]:void 0)}});var fo=co.start;De({target:"String",proto:!0,forced:po},{padStart:function(e){return fo(this,e,arguments.length>1?arguments[1]:void 0)}}),De({target:"String",proto:!0},{repeat:so});var mo=Math.max,vo=Math.min,go=Math.floor,yo=/\$([$&'`]|\d\d?|<[^>]*>)/g,bo=/\$([$&'`]|\d\d?)/g;qi("replace",2,(function(e,t,n,r){var a=r.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE,i=r.REPLACE_KEEPS_$0,o=a?"$":"$0";return[function(n,r){var a=m(this),i=null==n?void 0:n[e];return void 0!==i?i.call(n,a,r):t.call(String(a),n,r)},function(e,r){if(!a&&i||"string"==typeof r&&-1===r.indexOf(o)){var u=n(t,e,this,r);if(u.done)return u.value}var l=C(e),c=String(this),p="function"==typeof r;p||(r=String(r));var h=l.global;if(h){var f=l.unicode;l.lastIndex=0}for(var d=[];;){var m=Yi(l,c);if(null===m)break;if(d.push(m),!h)break;""===String(m[0])&&(l.lastIndex=Xi(c,le(l.lastIndex),f))}for(var v,g="",y=0,b=0;b<d.length;b++){m=d[b];for(var x=String(m[0]),w=mo(vo(se(m.index),c.length),0),k=[],N=1;N<m.length;N++)k.push(void 0===(v=m[N])?v:String(v));var I=m.groups;if(p){var S=[x].concat(k,w,c);void 0!==I&&S.push(I);var T=String(r.apply(void 0,S))}else T=s(x,c,w,k,I,r);w>=y&&(g+=c.slice(y,w)+T,y=w+x.length)}return g+c.slice(y)}];function s(e,n,r,a,i,o){var s=r+e.length,u=a.length,l=bo;return void 0!==i&&(i=Me(i),l=yo),t.call(o,l,(function(t,o){var l;switch(o.charAt(0)){case"$":return"$";case"&":return e;case"`":return n.slice(0,r);case"'":return n.slice(s);case"<":l=i[o.slice(1,-1)];break;default:var c=+o;if(0===c)return t;if(c>u){var p=go(c/10);return 0===p?t:p<=u?void 0===a[p-1]?o.charAt(1):a[p-1]+o.charAt(1):t}l=a[c-1]}return void 0===l?"":l}))}})),qi("search",1,(function(e,t,n){return[function(t){var n=m(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](String(n))},function(e){var r=n(t,e,this);if(r.done)return r.value;var a=C(e),i=String(this),o=a.lastIndex;An(o,0)||(a.lastIndex=0);var s=Yi(a,i);return An(a.lastIndex,o)||(a.lastIndex=o),null===s?-1:s.index}]}));var xo=[].push,wo=Math.min,ko=!i((function(){return!RegExp(4294967295,"y")}));qi("split",2,(function(e,t,n){var r;return r="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(e,n){var r=String(m(this)),a=void 0===n?4294967295:n>>>0;if(0===a)return[];if(void 0===e)return[r];if(!wi(e))return t.call(r,e,a);for(var i,o,s,u=[],l=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),c=0,p=new RegExp(e.source,l+"g");(i=Bi.call(p,r))&&!((o=p.lastIndex)>c&&(u.push(r.slice(c,i.index)),i.length>1&&i.index<r.length&&xo.apply(u,i.slice(1)),s=i[0].length,c=o,u.length>=a));)p.lastIndex===i.index&&p.lastIndex++;return c===r.length?!s&&p.test("")||u.push(""):u.push(r.slice(c)),u.length>a?u.slice(0,a):u}:"0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:t.call(this,e,n)}:t,[function(t,n){var a=m(this),i=null==t?void 0:t[e];return void 0!==i?i.call(t,a,n):r.call(String(a),t,n)},function(e,a){var i=n(r,e,this,a,r!==t);if(i.done)return i.value;var o=C(e),s=String(this),u=Zi(o,RegExp),l=o.unicode,c=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(ko?"y":"g"),p=new u(ko?o:"^(?:"+o.source+")",c),h=void 0===a?4294967295:a>>>0;if(0===h)return[];if(0===s.length)return null===Yi(p,s)?[s]:[];for(var f=0,d=0,m=[];d<s.length;){p.lastIndex=ko?d:0;var v,g=Yi(p,ko?s:s.slice(d));if(null===g||(v=wo(le(p.lastIndex+(ko?0:d)),s.length))===f)d=Xi(s,d,l);else{if(m.push(s.slice(f,d)),m.length===h)return m;for(var y=1;y<=g.length-1;y++)if(m.push(g[y]),m.length===h)return m;d=f=v}}return m.push(s.slice(f)),m}]}),!ko);var No=T.f,Io="".startsWith,So=Math.min,To=Ii("startsWith"),Co=!To&&!!function(){var e=No(String.prototype,"startsWith");return e&&!e.writable}();De({target:"String",proto:!0,forced:!Co&&!To},{startsWith:function(e){var t=String(m(this));ki(e);var n=le(So(arguments.length>1?arguments[1]:void 0,t.length)),r=String(e);return Io?Io.call(t,r,n):t.slice(n,n+r.length)===r}});var Eo="\t\n\v\f\r                　\u2028\u2029\ufeff",Ro="["+Eo+"]",Ao=RegExp("^"+Ro+Ro+"*"),Do=RegExp(Ro+Ro+"*$"),Fo=function(e){return function(t){var n=String(m(t));return 1&e&&(n=n.replace(Ao,"")),2&e&&(n=n.replace(Do,"")),n}},_o={start:Fo(1),end:Fo(2),trim:Fo(3)},Oo=function(e){return i((function(){return!!Eo[e]()||"​᠎"!="​᠎"[e]()||Eo[e].name!==e}))},Mo=_o.trim;De({target:"String",proto:!0,forced:Oo("trim")},{trim:function(){return Mo(this)}});var Lo=_o.start,zo=Oo("trimStart"),Po=zo?function(){return Lo(this)}:"".trimStart;De({target:"String",proto:!0,forced:zo},{trimStart:Po,trimLeft:Po});var Bo=_o.end,Wo=Oo("trimEnd"),Vo=Wo?function(){return Bo(this)}:"".trimEnd;De({target:"String",proto:!0,forced:Wo},{trimEnd:Vo,trimRight:Vo});var Uo=gi.charAt,Go=ee.set,jo=ee.getterFor("String Iterator");li(String,"String",(function(e){Go(this,{type:"String Iterator",string:String(e),index:0})}),(function(){var e,t=jo(this),n=t.string,r=t.index;return r>=n.length?{value:void 0,done:!0}:(e=Uo(n,r),t.index+=e.length,{value:e,done:!1})}));var Ho=/"/g,qo=function(e,t,n,r){var a=String(m(e)),i="<"+t;return""!==n&&(i+=" "+n+'="'+String(r).replace(Ho,"&quot;")+'"'),i+">"+a+"</"+t+">"},Ko=function(e){return i((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))};De({target:"String",proto:!0,forced:Ko("anchor")},{anchor:function(e){return qo(this,"a","name",e)}}),De({target:"String",proto:!0,forced:Ko("big")},{big:function(){return qo(this,"big","","")}}),De({target:"String",proto:!0,forced:Ko("blink")},{blink:function(){return qo(this,"blink","","")}}),De({target:"String",proto:!0,forced:Ko("bold")},{bold:function(){return qo(this,"b","","")}}),De({target:"String",proto:!0,forced:Ko("fixed")},{fixed:function(){return qo(this,"tt","","")}}),De({target:"String",proto:!0,forced:Ko("fontcolor")},{fontcolor:function(e){return qo(this,"font","color",e)}}),De({target:"String",proto:!0,forced:Ko("fontsize")},{fontsize:function(e){return qo(this,"font","size",e)}}),De({target:"String",proto:!0,forced:Ko("italics")},{italics:function(){return qo(this,"i","","")}}),De({target:"String",proto:!0,forced:Ko("link")},{link:function(e){return qo(this,"a","href",e)}}),De({target:"String",proto:!0,forced:Ko("small")},{small:function(){return qo(this,"small","","")}}),De({target:"String",proto:!0,forced:Ko("strike")},{strike:function(){return qo(this,"strike","","")}}),De({target:"String",proto:!0,forced:Ko("sub")},{sub:function(){return qo(this,"sub","","")}}),De({target:"String",proto:!0,forced:Ko("sup")},{sup:function(){return qo(this,"sup","","")}});var Xo=function(e,t,n){var r,a;return Hn&&"function"==typeof(r=t.constructor)&&r!==n&&g(a=r.prototype)&&a!==n.prototype&&Hn(e,a),e},Yo=R.f,Jo=be.f,Zo=ee.set,Qo=Ze("match"),$o=a.RegExp,es=$o.prototype,ts=/a/g,ns=/a/g,rs=new $o(ts)!==ts,as=Fi.UNSUPPORTED_Y;if(o&&Re("RegExp",!rs||as||i((function(){return ns[Qo]=!1,$o(ts)!=ts||$o(ns)==ns||"/a/i"!=$o(ts,"i")})))){for(var is=function(e,t){var n,r=this instanceof is,a=wi(e),i=void 0===t;if(!r&&a&&e.constructor===is&&i)return e;rs?a&&!i&&(e=e.source):e instanceof is&&(i&&(t=Ai.call(e)),e=e.source),as&&(n=!!t&&t.indexOf("y")>-1)&&(t=t.replace(/y/g,""));var o=Xo(rs?new $o(e,t):$o(e,t),r?this:es,is);return as&&n&&Zo(o,{sticky:n}),o},os=function(e){e in is||Yo(is,e,{configurable:!0,get:function(){return $o[e]},set:function(t){$o[e]=t}})},ss=Jo($o),us=0;ss.length>us;)os(ss[us++]);es.constructor=is,is.prototype=es,te(a,"RegExp",is)}Ya("RegExp"),o&&("g"!=/./g.flags||Fi.UNSUPPORTED_Y)&&R.f(RegExp.prototype,"flags",{configurable:!0,get:Ai});var ls=Fi.UNSUPPORTED_Y,cs=R.f,ps=ee.get,hs=RegExp.prototype;o&&ls&&cs(RegExp.prototype,"sticky",{configurable:!0,get:function(){if(this!==hs){if(this instanceof RegExp)return!!ps(this).sticky;throw TypeError("Incompatible receiver, RegExp required")}}});var fs=function(){var e=!1,t=/[ac]/;return t.exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e}(),ds=/./.test;De({target:"RegExp",proto:!0,forced:!fs},{test:function(e){if("function"!=typeof this.exec)return ds.call(this,e);var t=this.exec(e);if(null!==t&&!g(t))throw new Error("RegExp exec method returned something other than an Object or null");return!!t}});var ms=RegExp.prototype,vs=ms.toString,gs=i((function(){return"/a/b"!=vs.call({source:"a",flags:"b"})})),ys="toString"!=vs.name;(gs||ys)&&te(RegExp.prototype,"toString",(function(){var e=C(this),t=String(e.source),n=e.flags;return"/"+t+"/"+String(void 0===n&&e instanceof RegExp&&!("flags"in ms)?Ai.call(e):n)}),{unsafe:!0});var bs=_o.trim,xs=a.parseInt,ws=/^[+-]?0[Xx]/,ks=8!==xs(Eo+"08")||22!==xs(Eo+"0x16")?function(e,t){var n=bs(String(e));return xs(n,t>>>0||(ws.test(n)?16:10))}:xs;De({global:!0,forced:parseInt!=ks},{parseInt:ks});var Ns=_o.trim,Is=a.parseFloat,Ss=1/Is(Eo+"-0")!=-1/0?function(e){var t=Ns(String(e)),n=Is(t);return 0===n&&"-"==t.charAt(0)?-0:n}:Is;De({global:!0,forced:parseFloat!=Ss},{parseFloat:Ss});var Ts=be.f,Cs=T.f,Es=R.f,Rs=_o.trim,As=a.Number,Ds=As.prototype,Fs="Number"==h(Ge(Ds)),_s=function(e){var t,n,r,a,i,o,s,u,l=y(e,!1);if("string"==typeof l&&l.length>2)if(43===(t=(l=Rs(l)).charCodeAt(0))||45===t){if(88===(n=l.charCodeAt(2))||120===n)return NaN}else if(48===t){switch(l.charCodeAt(1)){case 66:case 98:r=2,a=49;break;case 79:case 111:r=8,a=55;break;default:return+l}for(o=(i=l.slice(2)).length,s=0;s<o;s++)if((u=i.charCodeAt(s))<48||u>a)return NaN;return parseInt(i,r)}return+l};if(Re("Number",!As(" 0o1")||!As("0b1")||As("+0x1"))){for(var Os,Ms=function(e){var t=arguments.length<1?0:e,n=this;return n instanceof Ms&&(Fs?i((function(){Ds.valueOf.call(n)})):"Number"!=h(n))?Xo(new As(_s(t)),n,Ms):_s(t)},Ls=o?Ts(As):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),zs=0;Ls.length>zs;zs++)x(As,Os=Ls[zs])&&!x(Ms,Os)&&Es(Ms,Os,Cs(As,Os));Ms.prototype=Ds,Ds.constructor=Ms,te(a,"Number",Ms)}De({target:"Number",stat:!0},{EPSILON:Math.pow(2,-52)});var Ps=a.isFinite,Bs=Number.isFinite||function(e){return"number"==typeof e&&Ps(e)};De({target:"Number",stat:!0},{isFinite:Bs});var Ws=Math.floor,Vs=function(e){return!g(e)&&isFinite(e)&&Ws(e)===e};De({target:"Number",stat:!0},{isInteger:Vs}),De({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var Us=Math.abs;De({target:"Number",stat:!0},{isSafeInteger:function(e){return Vs(e)&&Us(e)<=9007199254740991}}),De({target:"Number",stat:!0},{MAX_SAFE_INTEGER:9007199254740991}),De({target:"Number",stat:!0},{MIN_SAFE_INTEGER:-9007199254740991}),De({target:"Number",stat:!0,forced:Number.parseFloat!=Ss},{parseFloat:Ss}),De({target:"Number",stat:!0,forced:Number.parseInt!=ks},{parseInt:ks});var Gs=function(e){if("number"!=typeof e&&"Number"!=h(e))throw TypeError("Incorrect invocation");return+e},js=1..toFixed,Hs=Math.floor,qs=function e(t,n,r){return 0===n?r:n%2==1?e(t,n-1,r*t):e(t*t,n/2,r)},Ks=js&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==(0xde0b6b3a7640080).toFixed(0))||!i((function(){js.call({})}));De({target:"Number",proto:!0,forced:Ks},{toFixed:function(e){var t,n,r,a,i=Gs(this),o=se(e),s=[0,0,0,0,0,0],u="",l="0",c=function(e,t){for(var n=-1,r=t;++n<6;)r+=e*s[n],s[n]=r%1e7,r=Hs(r/1e7)},p=function(e){for(var t=6,n=0;--t>=0;)n+=s[t],s[t]=Hs(n/e),n=n%e*1e7},h=function(){for(var e=6,t="";--e>=0;)if(""!==t||0===e||0!==s[e]){var n=String(s[e]);t=""===t?n:t+so.call("0",7-n.length)+n}return t};if(o<0||o>20)throw RangeError("Incorrect fraction digits");if(i!=i)return"NaN";if(i<=-1e21||i>=1e21)return String(i);if(i<0&&(u="-",i=-i),i>1e-21)if(n=(t=function(e){for(var t=0,n=e;n>=4096;)t+=12,n/=4096;for(;n>=2;)t+=1,n/=2;return t}(i*qs(2,69,1))-69)<0?i*qs(2,-t,1):i/qs(2,t,1),n*=4503599627370496,(t=52-t)>0){for(c(0,n),r=o;r>=7;)c(1e7,0),r-=7;for(c(qs(10,r,1),0),r=t-1;r>=23;)p(1<<23),r-=23;p(1<<r),c(1,1),p(2),l=h()}else c(0,n),c(1<<-t,0),l=h()+so.call("0",o);return l=o>0?u+((a=l.length)<=o?"0."+so.call("0",o-a)+l:l.slice(0,a-o)+"."+l.slice(a-o)):u+l}});var Xs=1..toPrecision,Ys=i((function(){return"1"!==Xs.call(1,void 0)}))||!i((function(){Xs.call({})}));De({target:"Number",proto:!0,forced:Ys},{toPrecision:function(e){return void 0===e?Xs.call(Gs(this)):Xs.call(Gs(this),e)}});var Js=Math.log,Zs=Math.log1p||function(e){return(e=+e)>-1e-8&&e<1e-8?e-e*e/2:Js(1+e)},Qs=Math.acosh,$s=Math.log,eu=Math.sqrt,tu=Math.LN2,nu=!Qs||710!=Math.floor(Qs(Number.MAX_VALUE))||Qs(1/0)!=1/0;De({target:"Math",stat:!0,forced:nu},{acosh:function(e){return(e=+e)<1?NaN:e>94906265.62425156?$s(e)+tu:Zs(e-1+eu(e-1)*eu(e+1))}});var ru=Math.asinh,au=Math.log,iu=Math.sqrt;De({target:"Math",stat:!0,forced:!(ru&&1/ru(0)>0)},{asinh:function e(t){return isFinite(t=+t)&&0!=t?t<0?-e(-t):au(t+iu(t*t+1)):t}});var ou=Math.atanh,su=Math.log;De({target:"Math",stat:!0,forced:!(ou&&1/ou(-0)<0)},{atanh:function(e){return 0==(e=+e)?e:su((1+e)/(1-e))/2}});var uu=Math.sign||function(e){return 0==(e=+e)||e!=e?e:e<0?-1:1},lu=Math.abs,cu=Math.pow;De({target:"Math",stat:!0},{cbrt:function(e){return uu(e=+e)*cu(lu(e),1/3)}});var pu=Math.floor,hu=Math.log,fu=Math.LOG2E;De({target:"Math",stat:!0},{clz32:function(e){return(e>>>=0)?31-pu(hu(e+.5)*fu):32}});var du=Math.expm1,mu=Math.exp,vu=!du||du(10)>22025.465794806718||du(10)<22025.465794806718||-2e-17!=du(-2e-17)?function(e){return 0==(e=+e)?e:e>-1e-6&&e<1e-6?e+e*e/2:mu(e)-1}:du,gu=Math.cosh,yu=Math.abs,bu=Math.E;De({target:"Math",stat:!0,forced:!gu||gu(710)===1/0},{cosh:function(e){var t=vu(yu(e)-1)+1;return(t+1/(t*bu*bu))*(bu/2)}}),De({target:"Math",stat:!0,forced:vu!=Math.expm1},{expm1:vu});var xu=Math.abs,wu=Math.pow,ku=wu(2,-52),Nu=wu(2,-23),Iu=wu(2,127)*(2-Nu),Su=wu(2,-126),Tu=Math.fround||function(e){var t,n,r=xu(e),a=uu(e);return r<Su?a*(r/Su/Nu+1/ku-1/ku)*Su*Nu:(n=(t=(1+Nu/ku)*r)-(t-r))>Iu||n!=n?a*(1/0):a*n};De({target:"Math",stat:!0},{fround:Tu});var Cu=Math.hypot,Eu=Math.abs,Ru=Math.sqrt,Au=!!Cu&&Cu(1/0,NaN)!==1/0;De({target:"Math",stat:!0,forced:Au},{hypot:function(e,t){for(var n,r,a=0,i=0,o=arguments.length,s=0;i<o;)s<(n=Eu(arguments[i++]))?(a=a*(r=s/n)*r+1,s=n):a+=n>0?(r=n/s)*r:n;return s===1/0?1/0:s*Ru(a)}});var Du=Math.imul,Fu=i((function(){return-5!=Du(4294967295,5)||2!=Du.length}));De({target:"Math",stat:!0,forced:Fu},{imul:function(e,t){var n=+e,r=+t,a=65535&n,i=65535&r;return 0|a*i+((65535&n>>>16)*i+a*(65535&r>>>16)<<16>>>0)}});var _u=Math.log,Ou=Math.LOG10E;De({target:"Math",stat:!0},{log10:function(e){return _u(e)*Ou}}),De({target:"Math",stat:!0},{log1p:Zs});var Mu=Math.log,Lu=Math.LN2;De({target:"Math",stat:!0},{log2:function(e){return Mu(e)/Lu}}),De({target:"Math",stat:!0},{sign:uu});var zu=Math.abs,Pu=Math.exp,Bu=Math.E,Wu=i((function(){return-2e-17!=Math.sinh(-2e-17)}));De({target:"Math",stat:!0,forced:Wu},{sinh:function(e){return zu(e=+e)<1?(vu(e)-vu(-e))/2:(Pu(e-1)-Pu(-e-1))*(Bu/2)}});var Vu=Math.exp;De({target:"Math",stat:!0},{tanh:function(e){var t=vu(e=+e),n=vu(-e);return t==1/0?1:n==1/0?-1:(t-n)/(Vu(e)+Vu(-e))}}),rt(Math,"Math",!0);var Uu=Math.ceil,Gu=Math.floor;De({target:"Math",stat:!0},{trunc:function(e){return(e>0?Gu:Uu)(e)}}),De({target:"Date",stat:!0},{now:function(){return(new Date).getTime()}});var ju=i((function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}));De({target:"Date",proto:!0,forced:ju},{toJSON:function(e){var t=Me(this),n=y(t);return"number"!=typeof n||isFinite(n)?t.toISOString():null}});var Hu=co.start,qu=Math.abs,Ku=Date.prototype,Xu=Ku.getTime,Yu=Ku.toISOString,Ju=i((function(){return"0385-07-25T07:06:39.999Z"!=Yu.call(new Date(-50000000000001))}))||!i((function(){Yu.call(new Date(NaN))}))?function(){if(!isFinite(Xu.call(this)))throw RangeError("Invalid time value");var e=this.getUTCFullYear(),t=this.getUTCMilliseconds(),n=e<0?"-":e>9999?"+":"";return n+Hu(qu(e),n?6:4,0)+"-"+Hu(this.getUTCMonth()+1,2,0)+"-"+Hu(this.getUTCDate(),2,0)+"T"+Hu(this.getUTCHours(),2,0)+":"+Hu(this.getUTCMinutes(),2,0)+":"+Hu(this.getUTCSeconds(),2,0)+"."+Hu(t,3,0)+"Z"}:Yu;De({target:"Date",proto:!0,forced:Date.prototype.toISOString!==Ju},{toISOString:Ju});var Zu=Date.prototype,Qu=Zu.toString,$u=Zu.getTime;new Date(NaN)+""!="Invalid Date"&&te(Zu,"toString",(function(){var e=$u.call(this);return e==e?Qu.call(this):"Invalid Date"}));var el=Ze("toPrimitive"),tl=Date.prototype;el in tl||A(tl,el,(function(e){if("string"!==e&&"number"!==e&&"default"!==e)throw TypeError("Incorrect hint");return y(C(this),"number"!==e)}));var nl=ae("JSON","stringify"),rl=/[\uD800-\uDFFF]/g,al=/^[\uD800-\uDBFF]$/,il=/^[\uDC00-\uDFFF]$/,ol=function(e,t,n){var r=n.charAt(t-1),a=n.charAt(t+1);return al.test(e)&&!il.test(a)||il.test(e)&&!al.test(r)?"\\u"+e.charCodeAt(0).toString(16):e},sl=i((function(){return'"\\udf06\\ud834"'!==nl("\udf06\ud834")||'"\\udead"'!==nl("\udead")}));nl&&De({target:"JSON",stat:!0,forced:sl},{stringify:function(e,t,n){var r=nl.apply(null,arguments);return"string"==typeof r?r.replace(rl,ol):r}}),rt(a.JSON,"JSON",!0);var ul,ll,cl,pl=a.Promise,hl=function(e,t,n){for(var r in t)te(e,r,t[r],n);return e},fl=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e},dl=/(iphone|ipod|ipad).*applewebkit/i.test(gr),ml=a.location,vl=a.setImmediate,gl=a.clearImmediate,yl=a.process,bl=a.MessageChannel,xl=a.Dispatch,wl=0,kl={},Nl=function(e){if(kl.hasOwnProperty(e)){var t=kl[e];delete kl[e],t()}},Il=function(e){return function(){Nl(e)}},Sl=function(e){Nl(e.data)},Tl=function(e){a.postMessage(e+"",ml.protocol+"//"+ml.host)};vl&&gl||(vl=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return kl[++wl]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},ul(wl),wl},gl=function(e){delete kl[e]},"process"==h(yl)?ul=function(e){yl.nextTick(Il(e))}:xl&&xl.now?ul=function(e){xl.now(Il(e))}:bl&&!dl?(cl=(ll=new bl).port2,ll.port1.onmessage=Sl,ul=it(cl.postMessage,cl,1)):!a.addEventListener||"function"!=typeof postMessage||a.importScripts||i(Tl)||"file:"===ml.protocol?ul="onreadystatechange"in N("script")?function(e){Pe.appendChild(N("script")).onreadystatechange=function(){Pe.removeChild(this),Nl(e)}}:function(e){setTimeout(Il(e),0)}:(ul=Tl,a.addEventListener("message",Sl,!1)));var Cl,El,Rl,Al,Dl,Fl,_l,Ol,Ml={set:vl,clear:gl},Ll=T.f,zl=Ml.set,Pl=a.MutationObserver||a.WebKitMutationObserver,Bl=a.process,Wl=a.Promise,Vl="process"==h(Bl),Ul=Ll(a,"queueMicrotask"),Gl=Ul&&Ul.value;Gl||(Cl=function(){var e,t;for(Vl&&(e=Bl.domain)&&e.exit();El;){t=El.fn,El=El.next;try{t()}catch(e){throw El?Al():Rl=void 0,e}}Rl=void 0,e&&e.enter()},Vl?Al=function(){Bl.nextTick(Cl)}:Pl&&!dl?(Dl=!0,Fl=document.createTextNode(""),new Pl(Cl).observe(Fl,{characterData:!0}),Al=function(){Fl.data=Dl=!Dl}):Wl&&Wl.resolve?(_l=Wl.resolve(void 0),Ol=_l.then,Al=function(){Ol.call(_l,Cl)}):Al=function(){zl.call(a,Cl)});var jl,Hl,ql,Kl,Xl=Gl||function(e){var t={fn:e,next:void 0};Rl&&(Rl.next=t),El||(El=t,Al()),Rl=t},Yl=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r})),this.resolve=at(t),this.reject=at(n)},Jl={f:function(e){return new Yl(e)}},Zl=function(e,t){if(C(e),g(t)&&t.constructor===e)return t;var n=Jl.f(e);return(0,n.resolve)(t),n.promise},Ql=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},$l=Ml.set,ec=Ze("species"),tc="Promise",nc=ee.get,rc=ee.set,ac=ee.getterFor(tc),ic=pl,oc=a.TypeError,sc=a.document,uc=a.process,lc=ae("fetch"),cc=Jl.f,pc=cc,hc="process"==h(uc),fc=!!(sc&&sc.createEvent&&a.dispatchEvent),dc=Re(tc,(function(){if(!(z(ic)!==String(ic))){if(66===wr)return!0;if(!hc&&"function"!=typeof PromiseRejectionEvent)return!0}if(wr>=51&&/native code/.test(ic))return!1;var e=ic.resolve(1),t=function(e){e((function(){}),(function(){}))};return(e.constructor={})[ec]=t,!(e.then((function(){}))instanceof t)})),mc=dc||!hr((function(e){ic.all(e).catch((function(){}))})),vc=function(e){var t;return!(!g(e)||"function"!=typeof(t=e.then))&&t},gc=function(e,t,n){if(!t.notified){t.notified=!0;var r=t.reactions;Xl((function(){for(var a=t.value,i=1==t.state,o=0;r.length>o;){var s,u,l,c=r[o++],p=i?c.ok:c.fail,h=c.resolve,f=c.reject,d=c.domain;try{p?(i||(2===t.rejection&&wc(e,t),t.rejection=1),!0===p?s=a:(d&&d.enter(),s=p(a),d&&(d.exit(),l=!0)),s===c.promise?f(oc("Promise-chain cycle")):(u=vc(s))?u.call(s,h,f):h(s)):f(a)}catch(e){d&&!l&&d.exit(),f(e)}}t.reactions=[],t.notified=!1,n&&!t.rejection&&bc(e,t)}))}},yc=function(e,t,n){var r,i;fc?((r=sc.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),a.dispatchEvent(r)):r={promise:t,reason:n},(i=a["on"+e])?i(r):"unhandledrejection"===e&&function(e,t){var n=a.console;n&&n.error&&(1===arguments.length?n.error(e):n.error(e,t))}("Unhandled promise rejection",n)},bc=function(e,t){$l.call(a,(function(){var n,r=t.value;if(xc(t)&&(n=Ql((function(){hc?uc.emit("unhandledRejection",r,e):yc("unhandledrejection",e,r)})),t.rejection=hc||xc(t)?2:1,n.error))throw n.value}))},xc=function(e){return 1!==e.rejection&&!e.parent},wc=function(e,t){$l.call(a,(function(){hc?uc.emit("rejectionHandled",e):yc("rejectionhandled",e,t.value)}))},kc=function(e,t,n,r){return function(a){e(t,n,a,r)}},Nc=function(e,t,n,r){t.done||(t.done=!0,r&&(t=r),t.value=n,t.state=2,gc(e,t,!0))},Ic=function e(t,n,r,a){if(!n.done){n.done=!0,a&&(n=a);try{if(t===r)throw oc("Promise can't be resolved itself");var i=vc(r);i?Xl((function(){var a={done:!1};try{i.call(r,kc(e,t,a,n),kc(Nc,t,a,n))}catch(e){Nc(t,a,e,n)}})):(n.value=r,n.state=1,gc(t,n,!1))}catch(e){Nc(t,{done:!1},e,n)}}};dc&&(ic=function(e){fl(this,ic,tc),at(e),jl.call(this);var t=nc(this);try{e(kc(Ic,this,t),kc(Nc,this,t))}catch(e){Nc(this,t,e)}},(jl=function(e){rc(this,{type:tc,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=hl(ic.prototype,{then:function(e,t){var n=ac(this),r=cc(Zi(this,ic));return r.ok="function"!=typeof e||e,r.fail="function"==typeof t&&t,r.domain=hc?uc.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&gc(this,n,!1),r.promise},catch:function(e){return this.then(void 0,e)}}),Hl=function(){var e=new jl,t=nc(e);this.promise=e,this.resolve=kc(Ic,e,t),this.reject=kc(Nc,e,t)},Jl.f=cc=function(e){return e===ic||e===ql?new Hl(e):pc(e)},"function"==typeof pl&&(Kl=pl.prototype.then,te(pl.prototype,"then",(function(e,t){var n=this;return new ic((function(e,t){Kl.call(n,e,t)})).then(e,t)}),{unsafe:!0}),"function"==typeof lc&&De({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return Zl(ic,lc.apply(a,arguments))}}))),De({global:!0,wrap:!0,forced:dc},{Promise:ic}),rt(ic,tc,!1),Ya(tc),ql=ae(tc),De({target:tc,stat:!0,forced:dc},{reject:function(e){var t=cc(this);return t.reject.call(void 0,e),t.promise}}),De({target:tc,stat:!0,forced:dc},{resolve:function(e){return Zl(this,e)}}),De({target:tc,stat:!0,forced:mc},{all:function(e){var t=this,n=cc(t),r=n.resolve,a=n.reject,i=Ql((function(){var n=at(t.resolve),i=[],o=0,s=1;bn(e,(function(e){var u=o++,l=!1;i.push(void 0),s++,n.call(t,e).then((function(e){l||(l=!0,i[u]=e,--s||r(i))}),a)})),--s||r(i)}));return i.error&&a(i.value),n.promise},race:function(e){var t=this,n=cc(t),r=n.reject,a=Ql((function(){var a=at(t.resolve);bn(e,(function(e){a.call(t,e).then(n.resolve,r)}))}));return a.error&&r(a.value),n.promise}}),De({target:"Promise",stat:!0},{allSettled:function(e){var t=this,n=Jl.f(t),r=n.resolve,a=n.reject,i=Ql((function(){var n=at(t.resolve),a=[],i=0,o=1;bn(e,(function(e){var s=i++,u=!1;a.push(void 0),o++,n.call(t,e).then((function(e){u||(u=!0,a[s]={status:"fulfilled",value:e},--o||r(a))}),(function(e){u||(u=!0,a[s]={status:"rejected",reason:e},--o||r(a))}))})),--o||r(a)}));return i.error&&a(i.value),n.promise}});var Sc=!!pl&&i((function(){pl.prototype.finally.call({then:function(){}},(function(){}))}));De({target:"Promise",proto:!0,real:!0,forced:Sc},{finally:function(e){var t=Zi(this,ae("Promise")),n="function"==typeof e;return this.then(n?function(n){return Zl(t,e()).then((function(){return n}))}:e,n?function(n){return Zl(t,e()).then((function(){throw n}))}:e)}}),"function"!=typeof pl||pl.prototype.finally||te(pl.prototype,"finally",ae("Promise").prototype.finally);var Tc=function(e,t,n){var r=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),s=r?"set":"add",u=a[e],l=u&&u.prototype,c=u,p={},h=function(e){var t=l[e];te(l,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(o&&!g(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return o&&!g(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(o&&!g(e))&&t.call(this,0===e?0:e)}:function(e,n){return t.call(this,0===e?0:e,n),this})};if(Re(e,"function"!=typeof u||!(o||l.forEach&&!i((function(){(new u).entries().next()})))))c=n.getConstructor(t,e,r,s),nn.REQUIRED=!0;else if(Re(e,!0)){var f=new c,d=f[s](o?{}:-0,1)!=f,m=i((function(){f.has(1)})),v=hr((function(e){new u(e)})),y=!o&&i((function(){for(var e=new u,t=5;t--;)e[s](t,t);return!e.has(-0)}));v||((c=t((function(t,n){fl(t,c,e);var a=Xo(new u,t,c);return null!=n&&bn(n,a[s],a,r),a}))).prototype=l,l.constructor=c),(m||y)&&(h("delete"),h("has"),r&&h("get")),(y||d)&&h(s),o&&l.clear&&delete l.clear}return p[e]=c,De({global:!0,forced:c!=u},p),rt(c,e),o||n.setStrong(c,e,r),c},Cc=R.f,Ec=nn.fastKey,Rc=ee.set,Ac=ee.getterFor,Dc={getConstructor:function(e,t,n,r){var a=e((function(e,i){fl(e,a,t),Rc(e,{type:t,index:Ge(null),first:void 0,last:void 0,size:0}),o||(e.size=0),null!=i&&bn(i,e[r],e,n)})),i=Ac(t),s=function(e,t,n){var r,a,s=i(e),l=u(e,t);return l?l.value=n:(s.last=l={index:a=Ec(t,!0),key:t,value:n,previous:r=s.last,next:void 0,removed:!1},s.first||(s.first=l),r&&(r.next=l),o?s.size++:e.size++,"F"!==a&&(s.index[a]=l)),e},u=function(e,t){var n,r=i(e),a=Ec(t);if("F"!==a)return r.index[a];for(n=r.first;n;n=n.next)if(n.key==t)return n};return hl(a.prototype,{clear:function(){for(var e=i(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,o?e.size=0:this.size=0},delete:function(e){var t=i(this),n=u(this,e);if(n){var r=n.next,a=n.previous;delete t.index[n.index],n.removed=!0,a&&(a.next=r),r&&(r.previous=a),t.first==n&&(t.first=r),t.last==n&&(t.last=a),o?t.size--:this.size--}return!!n},forEach:function(e){for(var t,n=i(this),r=it(e,arguments.length>1?arguments[1]:void 0,3);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!u(this,e)}}),hl(a.prototype,n?{get:function(e){var t=u(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),o&&Cc(a.prototype,"size",{get:function(){return i(this).size}}),a},setStrong:function(e,t,n){var r=t+" Iterator",a=Ac(t),i=Ac(r);li(e,t,(function(e,t){Rc(this,{type:r,target:e,state:a(e),kind:t,last:void 0})}),(function(){for(var e=i(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),Ya(t)}},Fc=(Tc("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Dc),Tc("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Dc),nn.getWeakData),_c=ee.set,Oc=ee.getterFor,Mc=ct.find,Lc=ct.findIndex,zc=0,Pc=function(e){return e.frozen||(e.frozen=new Bc)},Bc=function(){this.entries=[]},Wc=function(e,t){return Mc(e.entries,(function(e){return e[0]===t}))};Bc.prototype={get:function(e){var t=Wc(this,e);if(t)return t[1]},has:function(e){return!!Wc(this,e)},set:function(e,t){var n=Wc(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=Lc(this.entries,(function(t){return t[0]===e}));return~t&&this.entries.splice(t,1),!!~t}};var Vc={getConstructor:function(e,t,n,r){var a=e((function(e,i){fl(e,a,t),_c(e,{type:t,id:zc++,frozen:void 0}),null!=i&&bn(i,e[r],e,n)})),i=Oc(t),o=function(e,t,n){var r=i(e),a=Fc(C(t),!0);return!0===a?Pc(r).set(t,n):a[r.id]=n,e};return hl(a.prototype,{delete:function(e){var t=i(this);if(!g(e))return!1;var n=Fc(e);return!0===n?Pc(t).delete(e):n&&x(n,t.id)&&delete n[t.id]},has:function(e){var t=i(this);if(!g(e))return!1;var n=Fc(e);return!0===n?Pc(t).has(e):n&&x(n,t.id)}}),hl(a.prototype,n?{get:function(e){var t=i(this);if(g(e)){var n=Fc(e);return!0===n?Pc(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return o(this,e,t)}}:{add:function(e){return o(this,e,!0)}}),a}};n((function(e){var t,n=ee.enforce,r=!a.ActiveXObject&&"ActiveXObject"in a,i=Object.isExtensible,o=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},s=e.exports=Tc("WeakMap",o,Vc);if(B&&r){t=Vc.getConstructor(o,"WeakMap",!0),nn.REQUIRED=!0;var u=s.prototype,l=u.delete,c=u.has,p=u.get,h=u.set;hl(u,{delete:function(e){if(g(e)&&!i(e)){var r=n(this);return r.frozen||(r.frozen=new t),l.call(this,e)||r.frozen.delete(e)}return l.call(this,e)},has:function(e){if(g(e)&&!i(e)){var r=n(this);return r.frozen||(r.frozen=new t),c.call(this,e)||r.frozen.has(e)}return c.call(this,e)},get:function(e){if(g(e)&&!i(e)){var r=n(this);return r.frozen||(r.frozen=new t),c.call(this,e)?p.call(this,e):r.frozen.get(e)}return p.call(this,e)},set:function(e,r){if(g(e)&&!i(e)){var a=n(this);a.frozen||(a.frozen=new t),c.call(this,e)?h.call(this,e,r):a.frozen.set(e,r)}else h.call(this,e,r);return this}})}}));Tc("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Vc);var Uc="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Gc=function(e){if(void 0===e)return 0;var t=se(e),n=le(t);if(t!==n)throw RangeError("Wrong length or index");return n},jc=Math.abs,Hc=Math.pow,qc=Math.floor,Kc=Math.log,Xc=Math.LN2,Yc=function(e,t,n){var r,a,i,o=new Array(n),s=8*n-t-1,u=(1<<s)-1,l=u>>1,c=23===t?Hc(2,-24)-Hc(2,-77):0,p=e<0||0===e&&1/e<0?1:0,h=0;for((e=jc(e))!=e||e===1/0?(a=e!=e?1:0,r=u):(r=qc(Kc(e)/Xc),e*(i=Hc(2,-r))<1&&(r--,i*=2),(e+=r+l>=1?c/i:c*Hc(2,1-l))*i>=2&&(r++,i/=2),r+l>=u?(a=0,r=u):r+l>=1?(a=(e*i-1)*Hc(2,t),r+=l):(a=e*Hc(2,l-1)*Hc(2,t),r=0));t>=8;o[h++]=255&a,a/=256,t-=8);for(r=r<<t|a,s+=t;s>0;o[h++]=255&r,r/=256,s-=8);return o[--h]|=128*p,o},Jc=function(e,t){var n,r=e.length,a=8*r-t-1,i=(1<<a)-1,o=i>>1,s=a-7,u=r-1,l=e[u--],c=127&l;for(l>>=7;s>0;c=256*c+e[u],u--,s-=8);for(n=c&(1<<-s)-1,c>>=-s,s+=t;s>0;n=256*n+e[u],u--,s-=8);if(0===c)c=1-o;else{if(c===i)return n?NaN:l?-1/0:1/0;n+=Hc(2,t),c-=o}return(l?-1:1)*n*Hc(2,c-t)},Zc=be.f,Qc=R.f,$c=ee.get,ep=ee.set,tp=a.ArrayBuffer,np=tp,rp=a.DataView,ap=rp&&rp.prototype,ip=Object.prototype,op=a.RangeError,sp=Yc,up=Jc,lp=function(e){return[255&e]},cp=function(e){return[255&e,e>>8&255]},pp=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},hp=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},fp=function(e){return sp(e,23,4)},dp=function(e){return sp(e,52,8)},mp=function(e,t){Qc(e.prototype,t,{get:function(){return $c(this)[t]}})},vp=function(e,t,n,r){var a=Gc(n),i=$c(e);if(a+t>i.byteLength)throw op("Wrong index");var o=$c(i.buffer).bytes,s=a+i.byteOffset,u=o.slice(s,s+t);return r?u:u.reverse()},gp=function(e,t,n,r,a,i){var o=Gc(n),s=$c(e);if(o+t>s.byteLength)throw op("Wrong index");for(var u=$c(s.buffer).bytes,l=o+s.byteOffset,c=r(+a),p=0;p<t;p++)u[l+p]=c[i?p:t-p-1]};if(Uc){if(!i((function(){tp(1)}))||!i((function(){new tp(-1)}))||i((function(){return new tp,new tp(1.5),new tp(NaN),"ArrayBuffer"!=tp.name}))){for(var yp,bp=(np=function(e){return fl(this,np),new tp(Gc(e))}).prototype=tp.prototype,xp=Zc(tp),wp=0;xp.length>wp;)(yp=xp[wp++])in np||A(np,yp,tp[yp]);bp.constructor=np}Hn&&En(ap)!==ip&&Hn(ap,ip);var kp=new rp(new np(2)),Np=ap.setInt8;kp.setInt8(0,2147483648),kp.setInt8(1,2147483649),!kp.getInt8(0)&&kp.getInt8(1)||hl(ap,{setInt8:function(e,t){Np.call(this,e,t<<24>>24)},setUint8:function(e,t){Np.call(this,e,t<<24>>24)}},{unsafe:!0})}else np=function(e){fl(this,np,"ArrayBuffer");var t=Gc(e);ep(this,{bytes:Vr.call(new Array(t),0),byteLength:t}),o||(this.byteLength=t)},rp=function(e,t,n){fl(this,rp,"DataView"),fl(e,np,"DataView");var r=$c(e).byteLength,a=se(t);if(a<0||a>r)throw op("Wrong offset");if(a+(n=void 0===n?r-a:le(n))>r)throw op("Wrong length");ep(this,{buffer:e,byteLength:n,byteOffset:a}),o||(this.buffer=e,this.byteLength=n,this.byteOffset=a)},o&&(mp(np,"byteLength"),mp(rp,"buffer"),mp(rp,"byteLength"),mp(rp,"byteOffset")),hl(rp.prototype,{getInt8:function(e){return vp(this,1,e)[0]<<24>>24},getUint8:function(e){return vp(this,1,e)[0]},getInt16:function(e){var t=vp(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=vp(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return hp(vp(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return hp(vp(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return up(vp(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return up(vp(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){gp(this,1,e,lp,t)},setUint8:function(e,t){gp(this,1,e,lp,t)},setInt16:function(e,t){gp(this,2,e,cp,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){gp(this,2,e,cp,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){gp(this,4,e,pp,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){gp(this,4,e,pp,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){gp(this,4,e,fp,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){gp(this,8,e,dp,t,arguments.length>2?arguments[2]:void 0)}});rt(np,"ArrayBuffer"),rt(rp,"DataView");var Ip={ArrayBuffer:np,DataView:rp},Sp=Ip.ArrayBuffer,Tp=a.ArrayBuffer;De({global:!0,forced:Tp!==Sp},{ArrayBuffer:Sp}),Ya("ArrayBuffer");var Cp,Ep=R.f,Rp=a.Int8Array,Ap=Rp&&Rp.prototype,Dp=a.Uint8ClampedArray,Fp=Dp&&Dp.prototype,_p=Rp&&En(Rp),Op=Ap&&En(Ap),Mp=Object.prototype,Lp=Mp.isPrototypeOf,zp=Ze("toStringTag"),Pp=G("TYPED_ARRAY_TAG"),Bp=Uc&&!!Hn&&"Opera"!==mn(a.opera),Wp=!1,Vp={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Up=function(e){return g(e)&&x(Vp,mn(e))};for(Cp in Vp)a[Cp]||(Bp=!1);if((!Bp||"function"!=typeof _p||_p===Function.prototype)&&(_p=function(){throw TypeError("Incorrect invocation")},Bp))for(Cp in Vp)a[Cp]&&Hn(a[Cp],_p);if((!Bp||!Op||Op===Mp)&&(Op=_p.prototype,Bp))for(Cp in Vp)a[Cp]&&Hn(a[Cp].prototype,Op);if(Bp&&En(Fp)!==Op&&Hn(Fp,Op),o&&!x(Op,zp))for(Cp in Wp=!0,Ep(Op,zp,{get:function(){return g(this)?this[Pp]:void 0}}),Vp)a[Cp]&&A(a[Cp],Pp,Cp);var Gp={NATIVE_ARRAY_BUFFER_VIEWS:Bp,TYPED_ARRAY_TAG:Wp&&Pp,aTypedArray:function(e){if(Up(e))return e;throw TypeError("Target is not a typed array")},aTypedArrayConstructor:function(e){if(Hn){if(Lp.call(_p,e))return e}else for(var t in Vp)if(x(Vp,Cp)){var n=a[t];if(n&&(e===n||Lp.call(n,e)))return e}throw TypeError("Target is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n){if(o){if(n)for(var r in Vp){var i=a[r];i&&x(i.prototype,e)&&delete i.prototype[e]}Op[e]&&!n||te(Op,e,n?t:Bp&&Ap[e]||t)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(o){if(Hn){if(n)for(r in Vp)(i=a[r])&&x(i,e)&&delete i[e];if(_p[e]&&!n)return;try{return te(_p,e,n?t:Bp&&Rp[e]||t)}catch(e){}}for(r in Vp)!(i=a[r])||i[e]&&!n||te(i,e,t)}},isView:function(e){var t=mn(e);return"DataView"===t||x(Vp,t)},isTypedArray:Up,TypedArray:_p,TypedArrayPrototype:Op};De({target:"ArrayBuffer",stat:!0,forced:!Gp.NATIVE_ARRAY_BUFFER_VIEWS},{isView:Gp.isView});var jp=Ip.ArrayBuffer,Hp=Ip.DataView,qp=jp.prototype.slice,Kp=i((function(){return!new jp(2).slice(1,void 0).byteLength}));De({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:Kp},{slice:function(e,t){if(void 0!==qp&&void 0===t)return qp.call(C(this),e);for(var n=C(this).byteLength,r=he(e,n),a=he(void 0===t?n:t,n),i=new(Zi(this,jp))(le(a-r)),o=new Hp(this),s=new Hp(i),u=0;r<a;)s.setUint8(u++,o.getUint8(r++));return i}}),De({global:!0,forced:!Uc},{DataView:Ip.DataView});var Xp=Gp.NATIVE_ARRAY_BUFFER_VIEWS,Yp=a.ArrayBuffer,Jp=a.Int8Array,Zp=!Xp||!i((function(){Jp(1)}))||!i((function(){new Jp(-1)}))||!hr((function(e){new Jp,new Jp(null),new Jp(1.5),new Jp(e)}),!0)||i((function(){return 1!==new Jp(new Yp(2),1,void 0).length})),Qp=function(e,t){var n=function(e){var t=se(e);if(t<0)throw RangeError("The argument can't be less than 0");return t}(e);if(n%t)throw RangeError("Wrong offset");return n},$p=Gp.aTypedArrayConstructor,eh=function(e){var t,n,r,a,i,o,s=Me(e),u=arguments.length,l=u>1?arguments[1]:void 0,c=void 0!==l,p=gn(s);if(null!=p&&!cn(p))for(o=(i=p.call(s)).next,s=[];!(a=o.call(i)).done;)s.push(a.value);for(c&&u>2&&(l=it(l,arguments[2],2)),n=le(s.length),r=new($p(this))(n),t=0;n>t;t++)r[t]=c?l(s[t],t):s[t];return r},th=n((function(e){var t=be.f,n=ct.forEach,r=ee.get,i=ee.set,s=R.f,u=T.f,l=Math.round,p=a.RangeError,h=Ip.ArrayBuffer,f=Ip.DataView,d=Gp.NATIVE_ARRAY_BUFFER_VIEWS,m=Gp.TYPED_ARRAY_TAG,v=Gp.TypedArray,b=Gp.TypedArrayPrototype,w=Gp.aTypedArrayConstructor,k=Gp.isTypedArray,N=function(e,t){for(var n=0,r=t.length,a=new(w(e))(r);r>n;)a[n]=t[n++];return a},I=function(e,t){s(e,t,{get:function(){return r(this)[t]}})},S=function(e){var t;return e instanceof h||"ArrayBuffer"==(t=mn(e))||"SharedArrayBuffer"==t},C=function(e,t){return k(e)&&"symbol"!=typeof t&&t in e&&String(+t)==String(t)},E=function(e,t){return C(e,t=y(t,!0))?c(2,e[t]):u(e,t)},D=function(e,t,n){return!(C(e,t=y(t,!0))&&g(n)&&x(n,"value"))||x(n,"get")||x(n,"set")||n.configurable||x(n,"writable")&&!n.writable||x(n,"enumerable")&&!n.enumerable?s(e,t,n):(e[t]=n.value,e)};o?(d||(T.f=E,R.f=D,I(b,"buffer"),I(b,"byteOffset"),I(b,"byteLength"),I(b,"length")),De({target:"Object",stat:!0,forced:!d},{getOwnPropertyDescriptor:E,defineProperty:D}),e.exports=function(e,o,u){var c=e.match(/\d+$/)[0]/8,y=e+(u?"Clamped":"")+"Array",x="get"+e,w="set"+e,I=a[y],T=I,C=T&&T.prototype,E={},R=function(e,t){s(e,t,{get:function(){return function(e,t){var n=r(e);return n.view[x](t*c+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,n){var a=r(e);u&&(n=(n=l(n))<0?0:n>255?255:255&n),a.view[w](t*c+a.byteOffset,n,!0)}(this,t,e)},enumerable:!0})};d?Zp&&(T=o((function(e,t,n,r){return fl(e,T,y),Xo(g(t)?S(t)?void 0!==r?new I(t,Qp(n,c),r):void 0!==n?new I(t,Qp(n,c)):new I(t):k(t)?N(T,t):eh.call(T,t):new I(Gc(t)),e,T)})),Hn&&Hn(T,v),n(t(I),(function(e){e in T||A(T,e,I[e])})),T.prototype=C):(T=o((function(e,t,n,r){fl(e,T,y);var a,o,s,u=0,l=0;if(g(t)){if(!S(t))return k(t)?N(T,t):eh.call(T,t);a=t,l=Qp(n,c);var d=t.byteLength;if(void 0===r){if(d%c)throw p("Wrong length");if((o=d-l)<0)throw p("Wrong length")}else if((o=le(r)*c)+l>d)throw p("Wrong length");s=o/c}else s=Gc(t),a=new h(o=s*c);for(i(e,{buffer:a,byteOffset:l,byteLength:o,length:s,view:new f(a)});u<s;)R(e,u++)})),Hn&&Hn(T,v),C=T.prototype=Ge(b)),C.constructor!==T&&A(C,"constructor",T),m&&A(C,m,y),E[y]=T,De({global:!0,forced:T!=I,sham:!d},E),"BYTES_PER_ELEMENT"in T||A(T,"BYTES_PER_ELEMENT",c),"BYTES_PER_ELEMENT"in C||A(C,"BYTES_PER_ELEMENT",c),Ya(y)}):e.exports=function(){}}));th("Int8",(function(e){return function(t,n,r){return e(this,t,n,r)}})),th("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}})),th("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}),!0),th("Int16",(function(e){return function(t,n,r){return e(this,t,n,r)}})),th("Uint16",(function(e){return function(t,n,r){return e(this,t,n,r)}})),th("Int32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),th("Uint32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),th("Float32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),th("Float64",(function(e){return function(t,n,r){return e(this,t,n,r)}})),(0,Gp.exportTypedArrayStaticMethod)("from",eh,Zp);var nh=Gp.aTypedArrayConstructor;(0,Gp.exportTypedArrayStaticMethod)("of",(function(){for(var e=0,t=arguments.length,n=new(nh(this))(t);t>e;)n[e]=arguments[e++];return n}),Zp);var rh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("copyWithin",(function(e,t){return Rr.call(rh(this),e,t,arguments.length>2?arguments[2]:void 0)}));var ah=ct.every,ih=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("every",(function(e){return ah(ih(this),e,arguments.length>1?arguments[1]:void 0)}));var oh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("fill",(function(e){return Vr.apply(oh(this),arguments)}));var sh=ct.filter,uh=Gp.aTypedArray,lh=Gp.aTypedArrayConstructor;(0,Gp.exportTypedArrayMethod)("filter",(function(e){for(var t=sh(uh(this),e,arguments.length>1?arguments[1]:void 0),n=Zi(this,this.constructor),r=0,a=t.length,i=new(lh(n))(a);a>r;)i[r]=t[r++];return i}));var ch=ct.find,ph=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("find",(function(e){return ch(ph(this),e,arguments.length>1?arguments[1]:void 0)}));var hh=ct.findIndex,fh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("findIndex",(function(e){return hh(fh(this),e,arguments.length>1?arguments[1]:void 0)}));var dh=ct.forEach,mh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("forEach",(function(e){dh(mh(this),e,arguments.length>1?arguments[1]:void 0)}));var vh=de.includes,gh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("includes",(function(e){return vh(gh(this),e,arguments.length>1?arguments[1]:void 0)}));var yh=de.indexOf,bh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("indexOf",(function(e){return yh(bh(this),e,arguments.length>1?arguments[1]:void 0)}));var xh=Ze("iterator"),wh=a.Uint8Array,kh=hi.values,Nh=hi.keys,Ih=hi.entries,Sh=Gp.aTypedArray,Th=Gp.exportTypedArrayMethod,Ch=wh&&wh.prototype[xh],Eh=!!Ch&&("values"==Ch.name||null==Ch.name),Rh=function(){return kh.call(Sh(this))};Th("entries",(function(){return Ih.call(Sh(this))})),Th("keys",(function(){return Nh.call(Sh(this))})),Th("values",Rh,!Eh),Th(xh,Rh,!Eh);var Ah=Gp.aTypedArray,Dh=[].join;(0,Gp.exportTypedArrayMethod)("join",(function(e){return Dh.apply(Ah(this),arguments)}));var Fh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("lastIndexOf",(function(e){return ga.apply(Fh(this),arguments)}));var _h=ct.map,Oh=Gp.aTypedArray,Mh=Gp.aTypedArrayConstructor;(0,Gp.exportTypedArrayMethod)("map",(function(e){return _h(Oh(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(Mh(Zi(e,e.constructor)))(t)}))}));var Lh=ka.left,zh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("reduce",(function(e){return Lh(zh(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var Ph=ka.right,Bh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("reduceRight",(function(e){return Ph(Bh(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var Wh=Gp.aTypedArray,Vh=Gp.exportTypedArrayMethod,Uh=Math.floor;Vh("reverse",(function(){for(var e,t=Wh(this).length,n=Uh(t/2),r=0;r<n;)e=this[r],this[r++]=this[--t],this[t]=e;return this}));var Gh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("set",(function(e){Gh(this);var t=Qp(arguments.length>1?arguments[1]:void 0,1),n=this.length,r=Me(e),a=le(r.length),i=0;if(a+t>n)throw RangeError("Wrong length");for(;i<a;)this[t+i]=r[i++]}),i((function(){new Int8Array(1).set({})})));var jh=Gp.aTypedArray,Hh=Gp.aTypedArrayConstructor,qh=[].slice;(0,Gp.exportTypedArrayMethod)("slice",(function(e,t){for(var n=qh.call(jh(this),e,t),r=Zi(this,this.constructor),a=0,i=n.length,o=new(Hh(r))(i);i>a;)o[a]=n[a++];return o}),i((function(){new Int8Array(1).slice()})));var Kh=ct.some,Xh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("some",(function(e){return Kh(Xh(this),e,arguments.length>1?arguments[1]:void 0)}));var Yh=Gp.aTypedArray,Jh=[].sort;(0,Gp.exportTypedArrayMethod)("sort",(function(e){return Jh.call(Yh(this),e)}));var Zh=Gp.aTypedArray;(0,Gp.exportTypedArrayMethod)("subarray",(function(e,t){var n=Zh(this),r=n.length,a=he(e,r);return new(Zi(n,n.constructor))(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,le((void 0===t?r:he(t,r))-a))}));var Qh=a.Int8Array,$h=Gp.aTypedArray,ef=Gp.exportTypedArrayMethod,tf=[].toLocaleString,nf=[].slice,rf=!!Qh&&i((function(){tf.call(new Qh(1))}));ef("toLocaleString",(function(){return tf.apply(rf?nf.call($h(this)):$h(this),arguments)}),i((function(){return[1,2].toLocaleString()!=new Qh([1,2]).toLocaleString()}))||!i((function(){Qh.prototype.toLocaleString.call([1,2])})));var af=Gp.exportTypedArrayMethod,of=a.Uint8Array,sf=of&&of.prototype||{},uf=[].toString,lf=[].join;i((function(){uf.call({})}))&&(uf=function(){return lf.call(this)});var cf=sf.toString!=uf;af("toString",uf,cf);var pf=ae("Reflect","apply"),hf=Function.apply,ff=!i((function(){pf((function(){}))}));De({target:"Reflect",stat:!0,forced:ff},{apply:function(e,t,n){return at(e),C(n),pf?pf(e,t,n):hf.call(e,t,n)}});var df=ae("Reflect","construct"),mf=i((function(){function e(){}return!(df((function(){}),[],e)instanceof e)})),vf=!i((function(){df((function(){}))})),gf=mf||vf;De({target:"Reflect",stat:!0,forced:gf,sham:gf},{construct:function(e,t){at(e),C(t);var n=arguments.length<3?e:at(arguments[2]);if(vf&&!mf)return df(e,t,n);if(e==n){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var r=[null];return r.push.apply(r,t),new(er.apply(e,r))}var a=n.prototype,i=Ge(g(a)?a:Object.prototype),o=Function.apply.call(e,i,t);return g(o)?o:i}});var yf=i((function(){Reflect.defineProperty(R.f({},1,{value:1}),1,{value:2})}));De({target:"Reflect",stat:!0,forced:yf,sham:!o},{defineProperty:function(e,t,n){C(e);var r=y(t,!0);C(n);try{return R.f(e,r,n),!0}catch(e){return!1}}});var bf=T.f;De({target:"Reflect",stat:!0},{deleteProperty:function(e,t){var n=bf(C(e),t);return!(n&&!n.configurable)&&delete e[t]}}),De({target:"Reflect",stat:!0},{get:function e(t,n){var r,a,i=arguments.length<3?t:arguments[2];return C(t)===i?t[n]:(r=T.f(t,n))?x(r,"value")?r.value:void 0===r.get?void 0:r.get.call(i):g(a=En(t))?e(a,n,i):void 0}}),De({target:"Reflect",stat:!0,sham:!o},{getOwnPropertyDescriptor:function(e,t){return T.f(C(e),t)}}),De({target:"Reflect",stat:!0,sham:!Sn},{getPrototypeOf:function(e){return En(C(e))}}),De({target:"Reflect",stat:!0},{has:function(e,t){return t in e}});var xf=Object.isExtensible;De({target:"Reflect",stat:!0},{isExtensible:function(e){return C(e),!xf||xf(e)}}),De({target:"Reflect",stat:!0},{ownKeys:we}),De({target:"Reflect",stat:!0,sham:!tn},{preventExtensions:function(e){C(e);try{var t=ae("Object","preventExtensions");return t&&t(e),!0}catch(e){return!1}}});var wf=i((function(){var e=R.f({},"a",{configurable:!0});return!1!==Reflect.set(En(e),"a",1,e)}));De({target:"Reflect",stat:!0,forced:wf},{set:function e(t,n,r){var a,i,o=arguments.length<4?t:arguments[3],s=T.f(C(t),n);if(!s){if(g(i=En(t)))return e(i,n,r,o);s=c(0)}if(x(s,"value")){if(!1===s.writable||!g(o))return!1;if(a=T.f(o,n)){if(a.get||a.set||!1===a.writable)return!1;a.value=r,R.f(o,n,a)}else R.f(o,n,c(0,r));return!0}return void 0!==s.set&&(s.set.call(o,r),!0)}}),Hn&&De({target:"Reflect",stat:!0},{setPrototypeOf:function(e,t){C(e),jn(t);try{return Hn(e,t),!0}catch(e){return!1}}});var kf={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0};for(var Nf in kf){var If=a[Nf],Sf=If&&If.prototype;if(Sf&&Sf.forEach!==ta)try{A(Sf,"forEach",ta)}catch(e){Sf.forEach=ta}}var Tf=Ze("iterator"),Cf=Ze("toStringTag"),Ef=hi.values;for(var Rf in kf){var Af=a[Rf],Df=Af&&Af.prototype;if(Df){if(Df[Tf]!==Ef)try{A(Df,Tf,Ef)}catch(e){Df[Tf]=Ef}if(Df[Cf]||A(Df,Cf,Rf),kf[Rf])for(var Ff in hi)if(Df[Ff]!==hi[Ff])try{A(Df,Ff,hi[Ff])}catch(e){Df[Ff]=hi[Ff]}}}var _f=!a.setImmediate||!a.clearImmediate;De({global:!0,bind:!0,enumerable:!0,forced:_f},{setImmediate:Ml.set,clearImmediate:Ml.clear});var Of=a.process,Mf="process"==h(Of);De({global:!0,enumerable:!0,noTargetGet:!0},{queueMicrotask:function(e){var t=Mf&&Of.domain;Xl(t?t.bind(e):e)}});var Lf=[].slice,zf=/MSIE .\./.test(gr),Pf=function(e){return function(t,n){var r=arguments.length>2,a=r?Lf.call(arguments,2):void 0;return e(r?function(){("function"==typeof t?t:Function(t)).apply(this,a)}:t,n)}};De({global:!0,bind:!0,forced:zf},{setTimeout:Pf(a.setTimeout),setInterval:Pf(a.setInterval)});var Bf=Ze("iterator"),Wf=!i((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[Bf]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host})),Vf=/[^\0-\u007E]/,Uf=/[.\u3002\uFF0E\uFF61]/g,Gf="Overflow: input needs wider integers to process",jf=Math.floor,Hf=String.fromCharCode,qf=function(e){return e+22+75*(e<26)},Kf=function(e,t,n){var r=0;for(e=n?jf(e/700):e>>1,e+=jf(e/t);e>455;r+=36)e=jf(e/35);return jf(r+36*e/(e+38))},Xf=function(e){var t,n,r=[],a=(e=function(e){for(var t=[],n=0,r=e.length;n<r;){var a=e.charCodeAt(n++);if(a>=55296&&a<=56319&&n<r){var i=e.charCodeAt(n++);56320==(64512&i)?t.push(((1023&a)<<10)+(1023&i)+65536):(t.push(a),n--)}else t.push(a)}return t}(e)).length,i=128,o=0,s=72;for(t=0;t<e.length;t++)(n=e[t])<128&&r.push(Hf(n));var u=r.length,l=u;for(u&&r.push("-");l<a;){var c=2147483647;for(t=0;t<e.length;t++)(n=e[t])>=i&&n<c&&(c=n);var p=l+1;if(c-i>jf((2147483647-o)/p))throw RangeError(Gf);for(o+=(c-i)*p,i=c,t=0;t<e.length;t++){if((n=e[t])<i&&++o>2147483647)throw RangeError(Gf);if(n==i){for(var h=o,f=36;;f+=36){var d=f<=s?1:f>=s+26?26:f-s;if(h<d)break;var m=h-d,v=36-d;r.push(Hf(qf(d+m%v))),h=jf(m/v)}r.push(Hf(qf(h))),s=Kf(o,p,l==u),o=0,++l}}++o,++i}return r.join("")},Yf=function(e){var t=gn(e);if("function"!=typeof t)throw TypeError(String(e)+" is not iterable");return C(t.call(e))},Jf=ae("fetch"),Zf=ae("Headers"),Qf=Ze("iterator"),$f=ee.set,ed=ee.getterFor("URLSearchParams"),td=ee.getterFor("URLSearchParamsIterator"),nd=/\+/g,rd=Array(4),ad=function(e){return rd[e-1]||(rd[e-1]=RegExp("((?:%[\\da-f]{2}){"+e+"})","gi"))},id=function(e){try{return decodeURIComponent(e)}catch(t){return e}},od=function(e){var t=e.replace(nd," "),n=4;try{return decodeURIComponent(t)}catch(e){for(;n;)t=t.replace(ad(n--),id);return t}},sd=/[!'()~]|%20/g,ud={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},ld=function(e){return ud[e]},cd=function(e){return encodeURIComponent(e).replace(sd,ld)},pd=function(e,t){if(t)for(var n,r,a=t.split("&"),i=0;i<a.length;)(n=a[i++]).length&&(r=n.split("="),e.push({key:od(r.shift()),value:od(r.join("="))}))},hd=function(e){this.entries.length=0,pd(this.entries,e)},fd=function(e,t){if(e<t)throw TypeError("Not enough arguments")},dd=ai((function(e,t){$f(this,{type:"URLSearchParamsIterator",iterator:Yf(ed(e).entries),kind:t})}),"Iterator",(function(){var e=td(this),t=e.kind,n=e.iterator.next(),r=n.value;return n.done||(n.value="keys"===t?r.key:"values"===t?r.value:[r.key,r.value]),n})),md=function(){fl(this,md,"URLSearchParams");var e,t,n,r,a,i,o,s,u,l=arguments.length>0?arguments[0]:void 0,c=this,p=[];if($f(c,{type:"URLSearchParams",entries:p,updateURL:function(){},updateSearchParams:hd}),void 0!==l)if(g(l))if("function"==typeof(e=gn(l)))for(n=(t=e.call(l)).next;!(r=n.call(t)).done;){if((o=(i=(a=Yf(C(r.value))).next).call(a)).done||(s=i.call(a)).done||!i.call(a).done)throw TypeError("Expected sequence with length 2");p.push({key:o.value+"",value:s.value+""})}else for(u in l)x(l,u)&&p.push({key:u,value:l[u]+""});else pd(p,"string"==typeof l?"?"===l.charAt(0)?l.slice(1):l:l+"")},vd=md.prototype;hl(vd,{append:function(e,t){fd(arguments.length,2);var n=ed(this);n.entries.push({key:e+"",value:t+""}),n.updateURL()},delete:function(e){fd(arguments.length,1);for(var t=ed(this),n=t.entries,r=e+"",a=0;a<n.length;)n[a].key===r?n.splice(a,1):a++;t.updateURL()},get:function(e){fd(arguments.length,1);for(var t=ed(this).entries,n=e+"",r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){fd(arguments.length,1);for(var t=ed(this).entries,n=e+"",r=[],a=0;a<t.length;a++)t[a].key===n&&r.push(t[a].value);return r},has:function(e){fd(arguments.length,1);for(var t=ed(this).entries,n=e+"",r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){fd(arguments.length,1);for(var n,r=ed(this),a=r.entries,i=!1,o=e+"",s=t+"",u=0;u<a.length;u++)(n=a[u]).key===o&&(i?a.splice(u--,1):(i=!0,n.value=s));i||a.push({key:o,value:s}),r.updateURL()},sort:function(){var e,t,n,r=ed(this),a=r.entries,i=a.slice();for(a.length=0,n=0;n<i.length;n++){for(e=i[n],t=0;t<n;t++)if(a[t].key>e.key){a.splice(t,0,e);break}t===n&&a.push(e)}r.updateURL()},forEach:function(e){for(var t,n=ed(this).entries,r=it(e,arguments.length>1?arguments[1]:void 0,3),a=0;a<n.length;)r((t=n[a++]).value,t.key,this)},keys:function(){return new dd(this,"keys")},values:function(){return new dd(this,"values")},entries:function(){return new dd(this,"entries")}},{enumerable:!0}),te(vd,Qf,vd.entries),te(vd,"toString",(function(){for(var e,t=ed(this).entries,n=[],r=0;r<t.length;)e=t[r++],n.push(cd(e.key)+"="+cd(e.value));return n.join("&")}),{enumerable:!0}),rt(md,"URLSearchParams"),De({global:!0,forced:!Wf},{URLSearchParams:md}),Wf||"function"!=typeof Jf||"function"!=typeof Zf||De({global:!0,enumerable:!0,forced:!0},{fetch:function(e){var t,n,r,a=[e];return arguments.length>1&&(t=arguments[1],g(t)&&(n=t.body,"URLSearchParams"===mn(n)&&((r=t.headers?new Zf(t.headers):new Zf).has("content-type")||r.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),t=Ge(t,{body:c(0,String(n)),headers:c(0,r)}))),a.push(t)),Jf.apply(this,a)}});var gd,yd={URLSearchParams:md,getState:ed},bd=gi.codeAt,xd=a.URL,wd=yd.URLSearchParams,kd=yd.getState,Nd=ee.set,Id=ee.getterFor("URL"),Sd=Math.floor,Td=Math.pow,Cd=/[A-Za-z]/,Ed=/[\d+-.A-Za-z]/,Rd=/\d/,Ad=/^(0x|0X)/,Dd=/^[0-7]+$/,Fd=/^\d+$/,_d=/^[\dA-Fa-f]+$/,Od=/[\u0000\u0009\u000A\u000D #%/:?@[\\]]/,Md=/[\u0000\u0009\u000A\u000D #/:?@[\\]]/,Ld=/^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g,zd=/[\u0009\u000A\u000D]/g,Pd=function(e,t){var n,r,a;if("["==t.charAt(0)){if("]"!=t.charAt(t.length-1))return"Invalid host";if(!(n=Wd(t.slice(1,-1))))return"Invalid host";e.host=n}else if(Xd(e)){if(t=function(e){var t,n,r=[],a=e.toLowerCase().replace(Uf,".").split(".");for(t=0;t<a.length;t++)n=a[t],r.push(Vf.test(n)?"xn--"+Xf(n):n);return r.join(".")}(t),Od.test(t))return"Invalid host";if(null===(n=Bd(t)))return"Invalid host";e.host=n}else{if(Md.test(t))return"Invalid host";for(n="",r=sr(t),a=0;a<r.length;a++)n+=qd(r[a],Ud);e.host=n}},Bd=function(e){var t,n,r,a,i,o,s,u=e.split(".");if(u.length&&""==u[u.length-1]&&u.pop(),(t=u.length)>4)return e;for(n=[],r=0;r<t;r++){if(""==(a=u[r]))return e;if(i=10,a.length>1&&"0"==a.charAt(0)&&(i=Ad.test(a)?16:8,a=a.slice(8==i?1:2)),""===a)o=0;else{if(!(10==i?Fd:8==i?Dd:_d).test(a))return e;o=parseInt(a,i)}n.push(o)}for(r=0;r<t;r++)if(o=n[r],r==t-1){if(o>=Td(256,5-t))return null}else if(o>255)return null;for(s=n.pop(),r=0;r<n.length;r++)s+=n[r]*Td(256,3-r);return s},Wd=function(e){var t,n,r,a,i,o,s,u=[0,0,0,0,0,0,0,0],l=0,c=null,p=0,h=function(){return e.charAt(p)};if(":"==h()){if(":"!=e.charAt(1))return;p+=2,c=++l}for(;h();){if(8==l)return;if(":"!=h()){for(t=n=0;n<4&&_d.test(h());)t=16*t+parseInt(h(),16),p++,n++;if("."==h()){if(0==n)return;if(p-=n,l>6)return;for(r=0;h();){if(a=null,r>0){if(!("."==h()&&r<4))return;p++}if(!Rd.test(h()))return;for(;Rd.test(h());){if(i=parseInt(h(),10),null===a)a=i;else{if(0==a)return;a=10*a+i}if(a>255)return;p++}u[l]=256*u[l]+a,2!=++r&&4!=r||l++}if(4!=r)return;break}if(":"==h()){if(p++,!h())return}else if(h())return;u[l++]=t}else{if(null!==c)return;p++,c=++l}}if(null!==c)for(o=l-c,l=7;0!=l&&o>0;)s=u[l],u[l--]=u[c+o-1],u[c+--o]=s;else if(8!=l)return;return u},Vd=function(e){var t,n,r,a;if("number"==typeof e){for(t=[],n=0;n<4;n++)t.unshift(e%256),e=Sd(e/256);return t.join(".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,a=0,i=0;i<8;i++)0!==e[i]?(a>n&&(t=r,n=a),r=null,a=0):(null===r&&(r=i),++a);return a>n&&(t=r,n=a),t}(e),n=0;n<8;n++)a&&0===e[n]||(a&&(a=!1),r===n?(t+=n?":":"::",a=!0):(t+=e[n].toString(16),n<7&&(t+=":")));return"["+t+"]"}return e},Ud={},Gd=Jt({},Ud,{" ":1,'"':1,"<":1,">":1,"`":1}),jd=Jt({},Gd,{"#":1,"?":1,"{":1,"}":1}),Hd=Jt({},jd,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),qd=function(e,t){var n=bd(e,0);return n>32&&n<127&&!x(t,e)?e:encodeURIComponent(e)},Kd={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Xd=function(e){return x(Kd,e.scheme)},Yd=function(e){return""!=e.username||""!=e.password},Jd=function(e){return!e.host||e.cannotBeABaseURL||"file"==e.scheme},Zd=function(e,t){var n;return 2==e.length&&Cd.test(e.charAt(0))&&(":"==(n=e.charAt(1))||!t&&"|"==n)},Qd=function(e){var t;return e.length>1&&Zd(e.slice(0,2))&&(2==e.length||"/"===(t=e.charAt(2))||"\\"===t||"?"===t||"#"===t)},$d=function(e){var t=e.path,n=t.length;!n||"file"==e.scheme&&1==n&&Zd(t[0],!0)||t.pop()},em=function(e){return"."===e||"%2e"===e.toLowerCase()},tm={},nm={},rm={},am={},im={},om={},sm={},um={},lm={},cm={},pm={},hm={},fm={},dm={},mm={},vm={},gm={},ym={},bm={},xm={},wm={},km=function(e,t,n,r){var a,i,o,s,u,l=n||tm,c=0,p="",h=!1,f=!1,d=!1;for(n||(e.scheme="",e.username="",e.password="",e.host=null,e.port=null,e.path=[],e.query=null,e.fragment=null,e.cannotBeABaseURL=!1,t=t.replace(Ld,"")),t=t.replace(zd,""),a=sr(t);c<=a.length;){switch(i=a[c],l){case tm:if(!i||!Cd.test(i)){if(n)return"Invalid scheme";l=rm;continue}p+=i.toLowerCase(),l=nm;break;case nm:if(i&&(Ed.test(i)||"+"==i||"-"==i||"."==i))p+=i.toLowerCase();else{if(":"!=i){if(n)return"Invalid scheme";p="",l=rm,c=0;continue}if(n&&(Xd(e)!=x(Kd,p)||"file"==p&&(Yd(e)||null!==e.port)||"file"==e.scheme&&!e.host))return;if(e.scheme=p,n)return void(Xd(e)&&Kd[e.scheme]==e.port&&(e.port=null));p="","file"==e.scheme?l=dm:Xd(e)&&r&&r.scheme==e.scheme?l=am:Xd(e)?l=um:"/"==a[c+1]?(l=im,c++):(e.cannotBeABaseURL=!0,e.path.push(""),l=bm)}break;case rm:if(!r||r.cannotBeABaseURL&&"#"!=i)return"Invalid scheme";if(r.cannotBeABaseURL&&"#"==i){e.scheme=r.scheme,e.path=r.path.slice(),e.query=r.query,e.fragment="",e.cannotBeABaseURL=!0,l=wm;break}l="file"==r.scheme?dm:om;continue;case am:if("/"!=i||"/"!=a[c+1]){l=om;continue}l=lm,c++;break;case im:if("/"==i){l=cm;break}l=ym;continue;case om:if(e.scheme=r.scheme,i==gd)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query;else if("/"==i||"\\"==i&&Xd(e))l=sm;else if("?"==i)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query="",l=xm;else{if("#"!=i){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.path.pop(),l=ym;continue}e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query,e.fragment="",l=wm}break;case sm:if(!Xd(e)||"/"!=i&&"\\"!=i){if("/"!=i){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,l=ym;continue}l=cm}else l=lm;break;case um:if(l=lm,"/"!=i||"/"!=p.charAt(c+1))continue;c++;break;case lm:if("/"!=i&&"\\"!=i){l=cm;continue}break;case cm:if("@"==i){h&&(p="%40"+p),h=!0,o=sr(p);for(var m=0;m<o.length;m++){var v=o[m];if(":"!=v||d){var g=qd(v,Hd);d?e.password+=g:e.username+=g}else d=!0}p=""}else if(i==gd||"/"==i||"?"==i||"#"==i||"\\"==i&&Xd(e)){if(h&&""==p)return"Invalid authority";c-=sr(p).length+1,p="",l=pm}else p+=i;break;case pm:case hm:if(n&&"file"==e.scheme){l=vm;continue}if(":"!=i||f){if(i==gd||"/"==i||"?"==i||"#"==i||"\\"==i&&Xd(e)){if(Xd(e)&&""==p)return"Invalid host";if(n&&""==p&&(Yd(e)||null!==e.port))return;if(s=Pd(e,p))return s;if(p="",l=gm,n)return;continue}"["==i?f=!0:"]"==i&&(f=!1),p+=i}else{if(""==p)return"Invalid host";if(s=Pd(e,p))return s;if(p="",l=fm,n==hm)return}break;case fm:if(!Rd.test(i)){if(i==gd||"/"==i||"?"==i||"#"==i||"\\"==i&&Xd(e)||n){if(""!=p){var y=parseInt(p,10);if(y>65535)return"Invalid port";e.port=Xd(e)&&y===Kd[e.scheme]?null:y,p=""}if(n)return;l=gm;continue}return"Invalid port"}p+=i;break;case dm:if(e.scheme="file","/"==i||"\\"==i)l=mm;else{if(!r||"file"!=r.scheme){l=ym;continue}if(i==gd)e.host=r.host,e.path=r.path.slice(),e.query=r.query;else if("?"==i)e.host=r.host,e.path=r.path.slice(),e.query="",l=xm;else{if("#"!=i){Qd(a.slice(c).join(""))||(e.host=r.host,e.path=r.path.slice(),$d(e)),l=ym;continue}e.host=r.host,e.path=r.path.slice(),e.query=r.query,e.fragment="",l=wm}}break;case mm:if("/"==i||"\\"==i){l=vm;break}r&&"file"==r.scheme&&!Qd(a.slice(c).join(""))&&(Zd(r.path[0],!0)?e.path.push(r.path[0]):e.host=r.host),l=ym;continue;case vm:if(i==gd||"/"==i||"\\"==i||"?"==i||"#"==i){if(!n&&Zd(p))l=ym;else if(""==p){if(e.host="",n)return;l=gm}else{if(s=Pd(e,p))return s;if("localhost"==e.host&&(e.host=""),n)return;p="",l=gm}continue}p+=i;break;case gm:if(Xd(e)){if(l=ym,"/"!=i&&"\\"!=i)continue}else if(n||"?"!=i)if(n||"#"!=i){if(i!=gd&&(l=ym,"/"!=i))continue}else e.fragment="",l=wm;else e.query="",l=xm;break;case ym:if(i==gd||"/"==i||"\\"==i&&Xd(e)||!n&&("?"==i||"#"==i)){if(".."===(u=(u=p).toLowerCase())||"%2e."===u||".%2e"===u||"%2e%2e"===u?($d(e),"/"==i||"\\"==i&&Xd(e)||e.path.push("")):em(p)?"/"==i||"\\"==i&&Xd(e)||e.path.push(""):("file"==e.scheme&&!e.path.length&&Zd(p)&&(e.host&&(e.host=""),p=p.charAt(0)+":"),e.path.push(p)),p="","file"==e.scheme&&(i==gd||"?"==i||"#"==i))for(;e.path.length>1&&""===e.path[0];)e.path.shift();"?"==i?(e.query="",l=xm):"#"==i&&(e.fragment="",l=wm)}else p+=qd(i,jd);break;case bm:"?"==i?(e.query="",l=xm):"#"==i?(e.fragment="",l=wm):i!=gd&&(e.path[0]+=qd(i,Ud));break;case xm:n||"#"!=i?i!=gd&&("'"==i&&Xd(e)?e.query+="%27":e.query+="#"==i?"%23":qd(i,Ud)):(e.fragment="",l=wm);break;case wm:i!=gd&&(e.fragment+=qd(i,Gd))}c++}},Nm=function(e){var t,n,r=fl(this,Nm,"URL"),a=arguments.length>1?arguments[1]:void 0,i=String(e),s=Nd(r,{type:"URL"});if(void 0!==a)if(a instanceof Nm)t=Id(a);else if(n=km(t={},String(a)))throw TypeError(n);if(n=km(s,i,null,t))throw TypeError(n);var u=s.searchParams=new wd,l=kd(u);l.updateSearchParams(s.query),l.updateURL=function(){s.query=String(u)||null},o||(r.href=Sm.call(r),r.origin=Tm.call(r),r.protocol=Cm.call(r),r.username=Em.call(r),r.password=Rm.call(r),r.host=Am.call(r),r.hostname=Dm.call(r),r.port=Fm.call(r),r.pathname=_m.call(r),r.search=Om.call(r),r.searchParams=Mm.call(r),r.hash=Lm.call(r))},Im=Nm.prototype,Sm=function(){var e=Id(this),t=e.scheme,n=e.username,r=e.password,a=e.host,i=e.port,o=e.path,s=e.query,u=e.fragment,l=t+":";return null!==a?(l+="//",Yd(e)&&(l+=n+(r?":"+r:"")+"@"),l+=Vd(a),null!==i&&(l+=":"+i)):"file"==t&&(l+="//"),l+=e.cannotBeABaseURL?o[0]:o.length?"/"+o.join("/"):"",null!==s&&(l+="?"+s),null!==u&&(l+="#"+u),l},Tm=function(){var e=Id(this),t=e.scheme,n=e.port;if("blob"==t)try{return new URL(t.path[0]).origin}catch(e){return"null"}return"file"!=t&&Xd(e)?t+"://"+Vd(e.host)+(null!==n?":"+n:""):"null"},Cm=function(){return Id(this).scheme+":"},Em=function(){return Id(this).username},Rm=function(){return Id(this).password},Am=function(){var e=Id(this),t=e.host,n=e.port;return null===t?"":null===n?Vd(t):Vd(t)+":"+n},Dm=function(){var e=Id(this).host;return null===e?"":Vd(e)},Fm=function(){var e=Id(this).port;return null===e?"":String(e)},_m=function(){var e=Id(this),t=e.path;return e.cannotBeABaseURL?t[0]:t.length?"/"+t.join("/"):""},Om=function(){var e=Id(this).query;return e?"?"+e:""},Mm=function(){return Id(this).searchParams},Lm=function(){var e=Id(this).fragment;return e?"#"+e:""},zm=function(e,t){return{get:e,set:t,configurable:!0,enumerable:!0}};if(o&&ze(Im,{href:zm(Sm,(function(e){var t=Id(this),n=String(e),r=km(t,n);if(r)throw TypeError(r);kd(t.searchParams).updateSearchParams(t.query)})),origin:zm(Tm),protocol:zm(Cm,(function(e){var t=Id(this);km(t,String(e)+":",tm)})),username:zm(Em,(function(e){var t=Id(this),n=sr(String(e));if(!Jd(t)){t.username="";for(var r=0;r<n.length;r++)t.username+=qd(n[r],Hd)}})),password:zm(Rm,(function(e){var t=Id(this),n=sr(String(e));if(!Jd(t)){t.password="";for(var r=0;r<n.length;r++)t.password+=qd(n[r],Hd)}})),host:zm(Am,(function(e){var t=Id(this);t.cannotBeABaseURL||km(t,String(e),pm)})),hostname:zm(Dm,(function(e){var t=Id(this);t.cannotBeABaseURL||km(t,String(e),hm)})),port:zm(Fm,(function(e){var t=Id(this);Jd(t)||(""==(e=String(e))?t.port=null:km(t,e,fm))})),pathname:zm(_m,(function(e){var t=Id(this);t.cannotBeABaseURL||(t.path=[],km(t,e+"",gm))})),search:zm(Om,(function(e){var t=Id(this);""==(e=String(e))?t.query=null:("?"==e.charAt(0)&&(e=e.slice(1)),t.query="",km(t,e,xm)),kd(t.searchParams).updateSearchParams(t.query)})),searchParams:zm(Mm),hash:zm(Lm,(function(e){var t=Id(this);""!=(e=String(e))?("#"==e.charAt(0)&&(e=e.slice(1)),t.fragment="",km(t,e,wm)):t.fragment=null}))}),te(Im,"toJSON",(function(){return Sm.call(this)}),{enumerable:!0}),te(Im,"toString",(function(){return Sm.call(this)}),{enumerable:!0}),xd){var Pm=xd.createObjectURL,Bm=xd.revokeObjectURL;Pm&&te(Nm,"createObjectURL",(function(e){return Pm.apply(xd,arguments)})),Bm&&te(Nm,"revokeObjectURL",(function(e){return Bm.apply(xd,arguments)}))}rt(Nm,"URL"),De({global:!0,forced:!Wf,sham:!o},{URL:Nm}),De({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return URL.prototype.toString.call(this)}});n((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function s(e,t,n,r){var a=t&&t.prototype instanceof c?t:c,i=Object.create(a.prototype),o=new k(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(a,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw i;return I()}for(n.method=a,n.arg=i;;){var o=n.delegate;if(o){var s=b(o,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var c=u(e,t,n);if("normal"===c.type){if(r=n.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r="completed",n.method="throw",n.arg=c.arg)}}}(e,n,o),i}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l={};function c(){}function p(){}function h(){}var f={};f[a]=function(){return this};var d=Object.getPrototypeOf,m=d&&d(d(N([])));m&&m!==t&&n.call(m,a)&&(f=m);var v=h.prototype=c.prototype=Object.create(f);function g(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function y(e,t){var r;this._invoke=function(a,i){function o(){return new t((function(r,o){!function r(a,i,o,s){var l=u(e[a],e,i);if("throw"!==l.type){var c=l.arg,p=c.value;return p&&"object"==typeof p&&n.call(p,"__await")?t.resolve(p.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(p).then((function(e){c.value=e,o(c)}),(function(e){return r("throw",e,o,s)}))}s(l.arg)}(a,i,r,o)}))}return r=r?r.then(o,o):o()}}function b(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=u(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var a=r.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function N(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:I}}function I(){return{value:void 0,done:!0}}return p.prototype=v.constructor=h,h.constructor=p,h[o]=p.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,o in e||(e[o]="GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},g(y.prototype),y.prototype[i]=function(){return this},e.AsyncIterator=y,e.async=function(t,n,r,a,i){void 0===i&&(i=Promise);var o=new y(s(t,n,r,a),i);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},g(v),v[o]="Generator",v[a]=function(){return this},v.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=N,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],o=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var i=a;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),w(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;w(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:N(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function Wm(e){this.wrapped=e}function Vm(e){var t,n;function r(t,n){try{var i=e[t](n),o=i.value,s=o instanceof Wm;Promise.resolve(s?o.wrapped:o).then((function(e){s?r("return"===t?"return":"next",e):a(i.done?"return":"normal",e)}),(function(e){r("throw",e)}))}catch(e){a("throw",e)}}function a(e,a){switch(e){case"return":t.resolve({value:a,done:!0});break;case"throw":t.reject(a);break;default:t.resolve({value:a,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,a){return new Promise((function(i,o){var s={key:e,arg:a,resolve:i,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,a))}))},"function"!=typeof e.return&&(this.return=void 0)}function Um(e,t,n,r,a,i,o){try{var s=e[i](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,a)}function Gm(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var i=e.apply(t,n);function o(e){Um(i,r,a,o,s,"next",e)}function s(e){Um(i,r,a,o,s,"throw",e)}o(void 0)}))}}function jm(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Hm(e,t,n){return t&&jm(e.prototype,t),n&&jm(e,n),e}function qm(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function Km(e){return(Km=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Xm(e,t){return(Xm=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ym(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function Jm(e,t,n){return(Jm=Ym()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&Xm(a,n.prototype),a}).apply(null,arguments)}function Zm(e){var t="function"==typeof Map?new Map:void 0;return(Zm=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return Jm(e,arguments,Km(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Xm(r,e)})(e)}function Qm(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function $m(e,t){if(e){if("string"==typeof e)return ev(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ev(e,t):void 0}}function ev(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function tv(e){var t=0;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=$m(e)))return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}"function"==typeof Symbol&&Symbol.asyncIterator&&(Vm.prototype[Symbol.asyncIterator]=function(){return this}),Vm.prototype.next=function(e){return this._invoke("next",e)},Vm.prototype.throw=function(e){return this._invoke("throw",e)},Vm.prototype.return=function(e){return this._invoke("return",e)};var nv=function(){function e(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}var t=e.prototype;return t.get=function(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)},t.set=function(e,t){this.dataIdsCount++,this.data.set(e,t)},t.has=function(e){return this.data.has(e)},t.delete=function(e){return this.dataIdsCount--,this.data.delete(e)},t.numDataIds=function(){return this.dataIdsCount},e}(),rv=function(){function e(){}var t=e.prototype;return t.time=function(e){return av("time")},t.read=function(e){return av("read")},t.readSync=function(e){return av("readSync")},t.numDataIds=function(){return av("numDataIds")},t.disposeData=function(e){return av("disposeData")},t.write=function(e,t,n){return av("write")},t.move=function(e,t,n,r){return av("move")},t.memory=function(){return av("memory")},t.floatPrecision=function(){return av("floatPrecision")},t.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4},t.batchMatMul=function(e,t,n,r){return av("batchMatMul")},t.fusedBatchMatMul=function(e){e.a,e.b,e.transposeA,e.transposeB,e.bias,e.activation,e.preluActivationWeights;return av("fusedBatchMatMul")},t.slice=function(e,t,n){return av("slice")},t.stridedSlice=function(e,t,n,r){return av("stridedSlice")},t.unstack=function(e,t){return av("unstack")},t.reverse=function(e,t){return av("reverse")},t.concat=function(e,t){return av("concat")},t.neg=function(e){return av("neg")},t.add=function(e,t){return av("add")},t.addN=function(e){return av("addN")},t.subtract=function(e,t){return av("subtract")},t.multiply=function(e,t){return av("multiply")},t.realDivide=function(e,t){return av("realDivide")},t.floorDiv=function(e,t){return av("floorDiv")},t.sum=function(e,t){return av("sum")},t.prod=function(e,t){return av("prod")},t.unsortedSegmentSum=function(e,t,n){return av("unsortedSegmentSum")},t.argMin=function(e,t){return av("argMin")},t.argMax=function(e,t){return av("argMax")},t.equal=function(e,t){return av("equal")},t.notEqual=function(e,t){return av("notEqual")},t.less=function(e,t){return av("less")},t.lessEqual=function(e,t){return av("lessEqual")},t.greater=function(e,t){return av("greater")},t.greaterEqual=function(e,t){return av("greaterEqual")},t.logicalNot=function(e){return av("logicalNot")},t.logicalAnd=function(e,t){return av("logicalAnd")},t.logicalOr=function(e,t){return av("logicalOr")},t.where=function(e){return av("where")},t.select=function(e,t,n){return av("select")},t.topk=function(e,t,n){return av("topk")},t.min=function(e,t){return av("min")},t.minimum=function(e,t){return av("minimum")},t.mod=function(e,t){return av("mod")},t.max=function(e,t){return av("max")},t.maximum=function(e,t){return av("maximum")},t.all=function(e,t){return av("all")},t.any=function(e,t){return av("any")},t.squaredDifference=function(e,t){return av("squaredDifference")},t.ceil=function(e){return av("ceil")},t.floor=function(e){return av("floor")},t.round=function(e){return av("round")},t.sign=function(e){return av("sign")},t.isNaN=function(e){return av("isNaN")},t.isInf=function(e){return av("isInf")},t.isFinite=function(e){return av("isFinite")},t.pow=function(e,t){return av("pow")},t.exp=function(e){return av("exp")},t.expm1=function(e){return av("expm1")},t.softmax=function(e,t){return av("softmax")},t.log=function(e){return av("log")},t.log1p=function(e){return av("log1p")},t.sqrt=function(e){return av("sqrt")},t.rsqrt=function(e){return av("rsqrt")},t.square=function(e){return av("square")},t.reciprocal=function(e){return av("reciprocal")},t.relu=function(e){return av("relu")},t.relu6=function(e){return av("relu6")},t.prelu=function(e,t){return av("prelu")},t.elu=function(e){return av("elu")},t.eluDer=function(e,t){return av("eluDer")},t.selu=function(e){return av("selu")},t.int=function(e){return av("int")},t.clip=function(e,t,n){return av("clip")},t.abs=function(e){return av("abs")},t.complexAbs=function(e){return av("complexAbs")},t.sigmoid=function(e){return av("sigmoid")},t.softplus=function(e){return av("softplus")},t.sin=function(e){return av("sin")},t.cos=function(e){return av("cos")},t.tan=function(e){return av("tan")},t.asin=function(e){return av("asin")},t.acos=function(e){return av("acos")},t.atan=function(e){return av("atan")},t.atan2=function(e,t){return av("atan2")},t.sinh=function(e){return av("sinh")},t.cosh=function(e){return av("cosh")},t.tanh=function(e){return av("tanh")},t.asinh=function(e){return av("asinh")},t.acosh=function(e){return av("acosh")},t.atanh=function(e){return av("atanh")},t.erf=function(e){return av("erf")},t.step=function(e,t){return av("step")},t.fusedConv2d=function(e){e.input,e.filter,e.convInfo,e.bias,e.activation,e.preluActivationWeights;return av("fusedConv2d")},t.conv2d=function(e,t,n){return av("conv2d")},t.conv2dDerInput=function(e,t,n){return av("conv2dDerInput")},t.conv2dDerFilter=function(e,t,n){return av("conv2dDerFilter")},t.fusedDepthwiseConv2D=function(e){e.input,e.filter,e.convInfo,e.bias,e.activation,e.preluActivationWeights;return av("fusedDepthwiseConv2D")},t.depthwiseConv2D=function(e,t,n){return av("depthwiseConv2D")},t.depthwiseConv2DDerInput=function(e,t,n){return av("depthwiseConv2DDerInput")},t.depthwiseConv2DDerFilter=function(e,t,n){return av("depthwiseConv2DDerFilter")},t.conv3d=function(e,t,n){return av("conv3d")},t.conv3dDerInput=function(e,t,n){return av("conv3dDerInput")},t.conv3dDerFilter=function(e,t,n){return av("conv3dDerFilter")},t.maxPool=function(e,t){return av("maxPool")},t.maxPoolBackprop=function(e,t,n,r){return av("maxPoolBackprop")},t.avgPool=function(e,t){return av("avgPool")},t.avgPoolBackprop=function(e,t,n){return av("avgPoolBackprop")},t.avgPool3d=function(e,t){return av("avgPool3d")},t.avgPool3dBackprop=function(e,t,n){return av("avgPool3dBackprop")},t.maxPool3d=function(e,t){return av("maxPool3d")},t.maxPool3dBackprop=function(e,t,n,r){return av("maxPool3dBackprop")},t.reshape=function(e,t){return av("reshape")},t.cast=function(e,t){return av("cast")},t.tile=function(e,t){return av("tile")},t.pad=function(e,t,n){return av("pad")},t.transpose=function(e,t){return av("transpose")},t.gather=function(e,t,n,r){return void 0===r&&(r=0),av("gather")},t.gatherND=function(e,t){return av("gatherND")},t.scatterND=function(e,t,n){return av("scatterND")},t.batchToSpaceND=function(e,t,n){return av("batchToSpaceND")},t.spaceToBatchND=function(e,t,n){return av("spaceToBatchND")},t.resizeBilinear=function(e,t,n,r,a){return av("resizeBilinear")},t.resizeBilinearBackprop=function(e,t,n){return av("resizeBilinearBackprop")},t.resizeNearestNeighbor=function(e,t,n,r,a){return av("resizeNearestNeighbor")},t.resizeNearestNeighborBackprop=function(e,t,n){return av("resizeNearestNeighborBackprop")},t.batchNorm=function(e,t,n,r,a,i){return av("batchNorm")},t.localResponseNormalization4D=function(e,t,n,r,a){return av("localResponseNormalization4D")},t.LRNGrad=function(e,t,n,r,a,i,o){return av("LRNGrad")},t.multinomial=function(e,t,n,r){return av("multinomial")},t.oneHot=function(e,t,n,r){return av("oneHot")},t.cumsum=function(e,t,n,r){return av("cumsum")},t.nonMaxSuppression=function(e,t,n,r,a){return av("nonMaxSuppression")},t.fft=function(e){return av("fft")},t.ifft=function(e){return av("ifft")},t.complex=function(e,t){return av("complex")},t.real=function(e){return av("real")},t.imag=function(e){return av("imag")},t.cropAndResize=function(e,t,n,r,a,i){return av("cropAndResize")},t.depthToSpace=function(e,t,n){return av("depthToSpace")},t.split=function(e,t,n){return av("split")},t.sparseToDense=function(e,t,n,r){return av("sparseToDense")},t.diag=function(e){return av("diag")},t.fill=function(e,t,n){return av("fill")},t.onesLike=function(e){return av("onesLike")},t.zerosLike=function(e){return av("zerosLike")},t.linspace=function(e,t,n){return av("linspace")},t.dispose=function(){return av("dispose")},e}();function av(e){throw new Error("'"+e+"' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen")}function iv(e){for(var t=e.length,n=0,r=0;t>0;)r=Math.random()*t|0,n=e[--t],e[t]=e[r],e[r]=n}function ov(e,t,n){return Math.max(e,Math.min(t,n))}function sv(e){return e%2==0?e:e+1}function uv(e){for(var t=0,n=0;n<e.length;n++)t+=e[n];return t}function lv(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function cv(e,t,n){void 0===n&&(n=""),lv(dv(e,t),(function(){return n+" Shapes "+e+" and "+t+" must match"}))}function pv(e){lv(null!=e,(function(){return"The input to the tensor constructor must be a non-null value."}))}function hv(e,t,n){if(void 0===t&&(t=[]),void 0===n&&(n=!1),null==t&&(t=[]),Array.isArray(e)||Cv(e)&&!n)for(var r=0;r<e.length;++r)hv(e[r],t,n);else t.push(e);return t}function fv(e){if(0===e.length)return 1;for(var t=e[0],n=1;n<e.length;n++)t*=e[n];return t}function dv(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function mv(e){return e%1==0}function vv(e){var t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function gv(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function yv(e,t,n){return void 0===t&&(t=function(e){return 0}),new Promise((function(r,a){var i=0;!function o(){if(e())r();else{i++;var s=t(i);null!=n&&i>=n?a():setTimeout(o,s)}}()}))}function bv(e,t){for(var n=1,r=-1,a=0;a<e.length;++a)if(e[a]>=0)n*=e[a];else if(-1===e[a]){if(-1!==r)throw Error("Shapes can only have 1 implicit size. Found -1 at dim "+r+" and dim "+a);r=a}else if(e[a]<0)throw Error("Shapes can not be < 0. Found "+e[a]+" at dim "+a);if(-1===r){if(t>0&&t!==n)throw Error("Size("+t+") must match the product of shape "+e);return e}if(0===n)throw Error("Cannot infer the missing size in ["+e+"] when there are 0 elements");if(t%n!=0)throw Error("The implicit shape can't be a fractional number. Got "+t+" / "+n);var i=e.slice();return i[r]=t/n,i}function xv(e,t){var n=t.length;return lv((e=null==e?t.map((function(e,t){return t})):[].concat(e)).every((function(e){return e>=-n&&e<n})),(function(){return"All values in axis param must be in range [-"+n+", "+n+") but got axis "+e})),lv(e.every((function(e){return mv(e)})),(function(){return"All values in axis param must be integers but got axis "+e})),e.map((function(e){return e<0?n+e:e}))}function wv(e,t){for(var n=[],r=[],a=null!=t&&Array.isArray(t)&&0===t.length,i=null==t||a?null:xv(t,e).sort(),o=0,s=0;s<e.length;++s){if(null!=i){if(i[o]===s&&1!==e[s])throw new Error("Can't squeeze axis "+s+" since its dim '"+e[s]+"' is not 1");(null==i[o]||i[o]>s)&&1===e[s]&&(n.push(e[s]),r.push(s)),i[o]<=s&&o++}1!==e[s]&&(n.push(e[s]),r.push(s))}return{newShape:n,keptDims:r}}function kv(e,t){var n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else{if("bool"!==e)throw new Error("Unknown data type "+e);n=new Uint8Array(t)}return n}function Nv(e,t){var n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error("Unknown data type "+e);n=new Array(t)}return n}function Iv(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(isNaN(r)||!isFinite(r))throw Error("A tensor of type "+t+" being uploaded contains "+r+".")}}function Sv(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}function Tv(e,t){return"complex64"!==t&&(("float32"!==t||"complex64"===e)&&(("int32"!==t||"float32"===e||"complex64"===e)&&("bool"!==t||"bool"!==e)))}function Cv(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array}function Ev(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error("Unknown dtype "+e)}function Rv(e){if(null==e)return 0;var t=0;return e.forEach((function(e){return t+=e.length})),t}function Av(e){return"string"==typeof e||e instanceof String}function Dv(e){return"boolean"==typeof e}function Fv(e){return"number"==typeof e}function _v(e){return Array.isArray(e)?_v(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array?"int32":Fv(e)?"float32":Av(e)?"string":Dv(e)?"bool":"float32"}function Ov(e){return!!(e&&e.constructor&&e.call&&e.apply)}function Mv(e,t){for(var n=t;n<e;++n)if(e%n==0)return n;return e}function Lv(e){var t=e.length;if(t<2)return[];var n=new Array(t-1);n[t-2]=e[t-1];for(var r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}function zv(e,t){if(0===e.length)return t[0];var n=e.reduce((function(e,t){return e*t}));if(0===n)return[];if(n!==t.length)throw new Error("["+e+"] does not match the input size "+t.length+".");return function e(t,n,r){var a=new Array;if(1===n.length)for(var i=n[0],o=0;o<i;o++)a[o]=r[t+o];else for(var s=n[0],u=n.slice(1),l=u.reduce((function(e,t){return e*t})),c=0;c<s;c++)a[c]=e(t+c*l,u,r);return a}(0,e,t)}function Pv(e,t){for(var n=Bv(e,t),r=0;r<n.length;r++)n[r]=1;return n}function Bv(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error("Unknown data type "+t)}function Wv(e,t){var n=e.reduce((function(e,t){return e*t}),1);if(null==t||"float32"===t)return zv(e,new Float32Array(n));if("int32"===t)return zv(e,new Int32Array(n));if("bool"===t)return zv(e,new Uint8Array(n));throw new Error("Unknown data type "+t)}function Vv(e){e.forEach((function(t){lv(Number.isInteger(t)&&t>=0,(function(){return"Tensor must have a shape comprised of positive integers but got shape ["+e+"]."}))}))}function Uv(e,t,n){if(0===t)return 0;if(1===t)return e[0];for(var r=e[e.length-1],a=0;a<e.length-1;++a)r+=n[a]*e[a];return r}function Gv(e,t,n){if(0===t)return[];if(1===t)return[e];for(var r=new Array(t),a=0;a<r.length-1;++a)r[a]=Math.floor(e/n[a]),e-=r[a]*n[a];return r[r.length-1]=e,r}function jv(e){return e&&e.then&&"function"==typeof e.then}var Hv,qv=function(){function e(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.populateURLFlags()}var t=e.prototype;return t.setPlatform=function(e,t){null!=this.platform&&console.warn("Platform "+this.platformName+" has already been set. Overwriting the platform with "+t+"."),this.platformName=e,this.platform=t},t.registerFlag=function(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){var r=this.urlFlags[e];console.warn("Setting feature override from URL "+e+": "+r+"."),this.set(e,r)}},t.getAsync=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t in this.flags)){e.next=2;break}return e.abrupt("return",this.flags[t]);case 2:return e.next=4,this.evaluateFlag(t);case 4:return this.flags[t]=e.sent,e.abrupt("return",this.flags[t]);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.get=function(e){if(e in this.flags)return this.flags[e];var t=this.evaluateFlag(e);if(jv(t))throw new Error("Flag "+e+" cannot be synchronously evaluated. Please use getAsync() instead.");return this.flags[e]=t,this.flags[e]},t.getNumber=function(e){return this.get(e)},t.getBool=function(e){return this.get(e)},t.getFlags=function(){return this.flags},t.set=function(e,t){if(null==this.flagRegistry[e])throw new Error("Cannot set flag "+e+" as it has not been registered.");this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)},t.evaluateFlag=function(e){if(null==this.flagRegistry[e])throw new Error("Cannot evaluate flag '"+e+"': no evaluation function found.");return this.flagRegistry[e].evaluationFn()},t.setFlags=function(e){this.flags=Object.assign({},e)},t.reset=function(){this.flags={},this.urlFlags={},this.populateURLFlags()},t.populateURLFlags=function(){var e=this;if(void 0!==this.global&&void 0!==this.global.location&&void 0!==this.global.location.search){var t,n,r=(t=this.global.location.search,n={},t.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,(function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];return Kv(n,r[0],r[1]),r.join("=")})),n);if("tfjsflags"in r)r.tfjsflags.split(",").forEach((function(t){var n=t.split(":"),r=n[0],a=n[1];e.urlFlags[r]=function(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if(""+ +t===t)return+t;throw new Error("Could not parse value flag value "+t+" for flag "+e+".")}(r,a)}))}},Hm(e,[{key:"features",get:function(){return this.flags}}]),e}();function Kv(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}function Xv(){return e.ENV}function Yv(){if(null==Hv){var e;if("undefined"!=typeof window)e=window;else if("undefined"!=typeof global)e=global;else if("undefined"!=typeof process)e=process;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}Hv=e}return Hv}function Jv(e,t){var n,r=(null==(n=Yv())._tfGlobals&&(n._tfGlobals=new Map),n._tfGlobals);if(r.has(e))return r.get(e);var a=t();return r.set(e,a),r.get(e)}e.ENV=null;var Zv="Add",Qv="Cos",$v="Elu",eg="Erf",tg="Exp",ng="Log",rg="Mod",ag="Pow",ig="Sin",og="Sub",sg="Tan",ug=Jv("kernelRegistry",(function(){return new Map})),lg=Jv("gradRegistry",(function(){return new Map}));function cg(e,t){var n=mg(e,t);return ug.get(n)}function pg(e){return lg.get(e)}function hg(e){for(var t=ug.entries(),n=[];;){var r=t.next(),a=r.done,i=r.value;if(a)break;var o=i[0],s=i[1];o.split("_")[0]===e&&n.push(s)}return n}function fg(e){var t=e.kernelName,n=e.backendName,r=mg(t,n);ug.has(r)&&console.warn("The kernel '"+t+"' for backend '"+n+"' is already registered"),ug.set(r,e)}function dg(e){var t=e.kernelName;lg.has(t)&&Xv().getBool("DEBUG")&&console.warn("Overriding the gradient for '"+t+"'"),lg.set(t,e)}function mg(e,t){return t+"_"+e}function vg(e,t){return"string"===t?xg(e):gg([e],t)}function gg(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=hv(e)),Xv().getBool("DEBUG")&&Iv(e,t),function(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){for(var n=new Uint8Array(e.length),r=0;r<n.length;++r)0!==Math.round(e[r])&&(n[r]=1);return n}throw new Error("Unknown data type "+t)}function yg(){return Xv().platform.now()}function bg(e,t){return Xv().platform.fetch(e,t)}function xg(e,t){return void 0===t&&(t="utf-8"),t=t||"utf-8",Xv().platform.encode(e,t)}function wg(e,t){return void 0===t&&(t="utf-8"),t=t||"utf-8",Xv().platform.decode(e,t)}var kg={__proto__:null,createScalarValue:vg,toTypedArray:gg,now:yg,fetch:bg,encodeString:xg,decodeString:wg,shuffle:iv,clamp:ov,nearestLargerEven:sv,sum:uv,randUniform:function(e,t){var n=Math.random();return t*n+(1-n)*e},distSquared:function(e,t){for(var n=0,r=0;r<e.length;r++){var a=Number(e[r])-Number(t[r]);n+=a*a}return n},assert:lv,assertShapesMatch:cv,assertNonNull:pv,flatten:hv,sizeFromShape:fv,isScalarShape:function(e){return 0===e.length},arraysEqual:dv,isInt:mv,tanh:function(e){if(null!=Math.tanh)return Math.tanh(e);if(e===1/0)return 1;if(e===-1/0)return-1;var t=Math.exp(2*e);return(t-1)/(t+1)},sizeToSquarishShape:vv,createShuffledIndices:function(e){for(var t=new Uint32Array(e),n=0;n<e;++n)t[n]=n;return iv(t),t},rightPad:gv,repeatedTry:yv,inferFromImplicitShape:bv,parseAxisParam:xv,squeezeShape:wv,getTypedArrayFromDType:kv,getArrayFromDType:Nv,checkConversionForErrors:Iv,isValidDtype:Sv,hasEncodingLoss:Tv,isTypedArray:Cv,bytesPerElement:Ev,bytesFromStringArray:Rv,isString:Av,isBoolean:Dv,isNumber:Fv,inferDtype:_v,isFunction:Ov,nearestDivisor:Mv,computeStrides:Lv,toNestedArray:zv,makeOnesTypedArray:Pv,makeZerosTypedArray:Bv,makeZerosNestedTypedArray:Wv,assertNonNegativeIntegerDimensions:Vv,locToIndex:Uv,indexToLoc:Gv,isPromise:jv},Ng=function(){function e(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new Ig)}var t=e.prototype;return t.profileKernel=function(e,t,n){var r,a=this.backendTimer.time((function(){r=n()}));if(Xv().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(var i=function(t){var n=r[t];n.data().then((function(t){!function(e,t,n){if("float32"!==t)return!1;for(var r=0;r<e.length;r++){var a=e[r];if(isNaN(a)||!isFinite(a))return console.warn("Found "+a+" in the result of '"+n+"'"),!0}}(t,n.dtype,e)}))},o=0;o<r.length;o++)i(o);return{kernelName:e,outputs:r,inputs:t,timeMs:a.then((function(e){return e.kernelMs})),extraInfo:a.then((function(e){return null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""}))}},t.logKernelProfile=function(e){var t=this,n=e.kernelName,r=e.outputs,a=e.timeMs,i=e.inputs,o=e.extraInfo;r.forEach((function(e){Promise.all([e.data(),a,o]).then((function(r){t.logger.logKernelProfile(n,e,r[0],r[1],i,r[2])}))}))},e}();var Ig=function(){function e(){}return e.prototype.logKernelProfile=function(e,t,n,r,a,i){var o="number"==typeof r?gv(r+"ms",9):r.error,s=gv(e,25),u=t.rank,l=t.size,c=gv(t.shape.toString(),14),p="";for(var h in a){var f=a[h];if(null!=f){var d=f.shape||t.shape,m=d.length;p+=h+": "+m+"D "+(m>0?d:"")+" "}}console.log("%c"+s+"\t%c"+o+"\t%c"+u+"D "+c+"\t%c"+l+"\t%c"+p+"\t%c"+i,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")},e}();function Sg(e,t,n,r){var a=Lv(t),i=function(e,t,n,r){var a=fv(t),i=r[r.length-1],o=new Array(i).fill(0),s=t.length,u="complex64"===n?Eg(e):e;if(s>1)for(var l=0;l<a/i;l++)for(var c=l*i,p=0;p<i;p++)o[p]=Math.max(o[p],Tg(u[c+p],0,n).length);return o}(e,t,n,a),o=t.length,s=function e(t,n,r,a,i,o){void 0===o&&(o=!0);var s="complex64"===r?2:1,u=n[0],l=n.length;if(0===l){return"complex64"===r?[Tg(Eg(t)[0],0,r)]:"bool"===r?[Cg(t[0])]:[t[0].toString()]}if(1===l){if(u>20){var c=3*s,p=Array.from(t.slice(0,c)),h=Array.from(t.slice((u-3)*s,u*s));return"complex64"===r&&(p=Eg(p),h=Eg(h)),["["+p.map((function(e,t){return Tg(e,i[t],r)})).join(", ")+", ..., "+h.map((function(e,t){return Tg(e,i[u-3+t],r)})).join(", ")+"]"]}return["["+("complex64"===r?Eg(t):Array.from(t)).map((function(e,t){return Tg(e,i[t],r)})).join(", ")+"]"]}var f=n.slice(1),d=a.slice(1),m=a[0]*s,v=[];if(u>20){for(var g=0;g<3;g++){var y=g*m,b=y+m;v.push.apply(v,e(t.slice(y,b),f,r,d,i,!1))}v.push("...");for(var x=u-3;x<u;x++){var w=x*m,k=w+m;v.push.apply(v,e(t.slice(w,k),f,r,d,i,x===u-1))}}else for(var N=0;N<u;N++){var I=N*m,S=I+m;v.push.apply(v,e(t.slice(I,S),f,r,d,i,N===u-1))}var T=2===l?",":"";v[0]="["+v[0]+T;for(var C=1;C<v.length-1;C++)v[C]=" "+v[C]+T;for(var E=",\n",R=2;R<l;R++)E+="\n";return v[v.length-1]=" "+v[v.length-1]+"]"+(o?"":E),v}(e,t,n,a,i),u=["Tensor"];return r&&(u.push("  dtype: "+n),u.push("  rank: "+o),u.push("  shape: ["+t+"]"),u.push("  values:")),u.push(s.map((function(e){return"    "+e})).join("\n")),u.join("\n")}function Tg(e,t,n){return gv(Array.isArray(e)?parseFloat(e[0].toFixed(7))+" + "+parseFloat(e[1].toFixed(7))+"j":Av(e)?"'"+e+"'":"bool"===n?Cg(e):parseFloat(e.toFixed(7)).toString(),t)}function Cg(e){return 0===e?"false":"true"}function Eg(e){for(var t=[],n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}var Rg=function(){function e(e,t,n){var r=this;if(this.dtype=t,this.shape=e.slice(),this.size=fv(e),null!=n){var a=n.length;lv(a===this.size,(function(){return"Length of values '"+a+"' does not match the size inferred by the shape '"+r.size+"'."}))}if("complex64"===t)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||Nv(t,this.size),this.strides=Lv(e)}var t=e.prototype;return t.set=function(e){for(var t=this,n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];0===r.length&&(r=[0]),lv(r.length===this.rank,(function(){return"The number of provided coordinates ("+r.length+") must match the rank ("+t.rank+")"}));var i=this.locToIndex(r);this.values[i]=e},t.get=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];0===t.length&&(t=[0]);for(var r=0,a=0,i=t;a<i.length;a++){var o=i[a];if(o<0||o>=this.shape[r]){var s="Requested out of range element at "+t+".   Buffer shape="+this.shape;throw new Error(s)}r++}for(var u=t[t.length-1],l=0;l<t.length-1;++l)u+=this.strides[l]*t[l];return this.values[u]},t.locToIndex=function(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];for(var t=e[e.length-1],n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t},t.indexToLoc=function(e){if(0===this.rank)return[];if(1===this.rank)return[e];for(var t=new Array(this.shape.length),n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t},t.toTensor=function(){return Ag().makeTensor(this.values,this.shape,this.dtype)},Hm(e,[{key:"rank",get:function(){return this.shape.length}}]),e}(),Ag=null,Dg=null;var Fg=function(){function e(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=fv(e),this.strides=Lv(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}var t=e.prototype;return t.buffer=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.data();case 2:return t=e.sent,e.abrupt("return",Dg.buffer(this.shape,this.dtype,t));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.bufferSync=function(){return Dg.buffer(this.shape,this.dtype,this.dataSync())},t.array=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.data();case 2:return t=e.sent,e.abrupt("return",zv(this.shape,t));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.arraySync=function(){return zv(this.shape,this.dataSync())},t.data=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.throwIfDisposed(),t=Ag().read(this.dataId),"string"!==this.dtype){e.next=13;break}return e.next=5,t;case 5:return n=e.sent,e.prev=6,e.abrupt("return",n.map((function(e){return wg(e)})));case 10:throw e.prev=10,e.t0=e.catch(6),new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");case 13:return e.abrupt("return",t);case 14:case"end":return e.stop()}}),e,this,[[6,10]])})));return function(){return e.apply(this,arguments)}}(),t.dataSync=function(){this.throwIfDisposed();var e=Ag().readSync(this.dataId);if("string"===this.dtype)try{return e.map((function(e){return wg(e)}))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e},t.bytes=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.throwIfDisposed(),e.next=3,Ag().read(this.dataId);case 3:if(t=e.sent,"string"!==this.dtype){e.next=8;break}return e.abrupt("return",t);case 8:return e.abrupt("return",new Uint8Array(t.buffer));case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.dispose=function(){this.isDisposed||(Ag().disposeTensor(this),this.isDisposedInternal=!0)},t.throwIfDisposed=function(){if(this.isDisposed)throw new Error("Tensor is disposed.")},t.print=function(e){return void 0===e&&(e=!1),Dg.print(this,e)},t.clone=function(){return this.throwIfDisposed(),Dg.clone(this)},t.toString=function(e){return void 0===e&&(e=!1),Sg(this.dataSync(),this.shape,this.dtype,e)},t.cast=function(e){return this.throwIfDisposed(),Dg.cast(this,e)},t.variable=function(e,t,n){return void 0===e&&(e=!0),this.throwIfDisposed(),Ag().makeVariable(this,e,t,n)},Hm(e,[{key:"rank",get:function(){return this.shape.length}},{key:"isDisposed",get:function(){return this.isDisposedInternal}}]),e}();Object.defineProperty(Fg,Symbol.hasInstance,{value:function(e){return!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}});var _g,Og,Mg,Lg,zg,Pg=function(e){function t(t,n,r,a){var i;return(i=e.call(this,t.shape,t.dtype,t.dataId,a)||this).trainable=n,i.name=r,i}qm(t,e);var n=t.prototype;return n.assign=function(e){if(e.dtype!==this.dtype)throw new Error("dtype of the new value ("+e.dtype+") and previous value ("+this.dtype+") must match");if(!dv(e.shape,this.shape))throw new Error("shape of the new value ("+e.shape+") and previous value ("+this.shape+") must match");Ag().disposeTensor(this),this.dataId=e.dataId,Ag().incRef(this,null)},n.dispose=function(){Ag().disposeVariable(this),this.isDisposedInternal=!0},t}(Fg);Object.defineProperty(Pg,Symbol.hasInstance,{value:function(e){return e instanceof Fg&&null!=e.assign&&e.assign instanceof Function}}),(_g=e.Rank||(e.Rank={})).R0="R0",_g.R1="R1",_g.R2="R2",_g.R3="R3",_g.R4="R4",_g.R5="R5",_g.R6="R6",function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(Og||(Og={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(Mg||(Mg={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(Lg||(Lg={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(zg||(zg={}));var Bg={float32:Lg,int32:Og,bool:Mg,complex64:zg};function Wg(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error("Can not upcast "+e+" with "+t)}return Bg[e][t]}function Vg(e){return Wg(e,"int32")}function Ug(e,t){if(e.dtype===t.dtype)return[e,t];var n=Wg(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function Gg(e,t){lv(e.dtype===t.dtype,(function(){return"The dtypes of the first("+e.dtype+") and second("+t.dtype+") input must match"}))}function jg(e,t){return t.some((function(t){return t.id===e.id}))}function Hg(e){var t=[];return function e(t,n,r){if(null==t)return;if(t instanceof Fg)return void n.push(t);if(a=t,!Array.isArray(a)&&"object"!=typeof a)return;var a;var i=t;for(var o in i){var s=i[o];r.has(s)||(r.add(s),e(s,n,r))}}(e,t,new Set),t}var qg={__proto__:null,makeTypesMatch:Ug,assertTypesMatch:Gg,isTensorInList:jg,getTensorsInContainer:Hg},Kg=function(){function e(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((function(e){return e.name}))))}}}return e.prototype.dispose=function(){for(var e in this.registeredVariables)this.registeredVariables[e].dispose()},e}(),Xg=function(){function e(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new Kg}var t=e.prototype;return t.ready=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==this.pendingBackendInit){e.next=2;break}return e.abrupt("return",this.pendingBackendInit.then((function(){})));case 2:if(null==this.backendInstance){e.next=4;break}return e.abrupt("return");case 4:t=this.getSortedBackends(),n=0;case 6:if(!(n<t.length)){e.next=18;break}return r=t[n],e.next=10,this.initializeBackend(r).success;case 10:if(!e.sent){e.next=15;break}return e.next=14,this.setBackend(r);case 14:return e.abrupt("return");case 15:n++,e.next=6;break;case 18:throw new Error("Could not initialize any backends, all backend initializations failed.");case 19:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.backendNames=function(){return Object.keys(this.registryFactory)},t.findBackend=function(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;if(this.initializeBackend(e).asyncInit)return null}return this.registry[e]},t.findBackendFactory=function(e){return e in this.registryFactory?this.registryFactory[e].factory:null},t.registerBackend=function(e,t,n){return void 0===n&&(n=1),e in this.registryFactory?(console.warn(e+" backend was already registered. Reusing existing backend factory."),!1):(this.registryFactory[e]={factory:t,priority:n},!0)},t.setBackend=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=this.registryFactory[t]){e.next=2;break}throw new Error("Backend name '"+t+"' not found in registry");case 2:if(this.backendName=t,null!=this.registry[t]){e.next=16;break}if(this.backendInstance=null,n=this.initializeBackend(t),r=n.success,!n.asyncInit){e.next=12;break}return e.next=9,r;case 9:e.t0=e.sent,e.next=13;break;case 12:e.t0=r;case 13:if(e.t0){e.next=16;break}return e.abrupt("return",!1);case 16:return this.backendInstance=this.registry[t],this.setupRegisteredKernels(),this.profiler=new Ng(this.backendInstance),e.abrupt("return",!0);case 20:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.setupRegisteredKernels=function(){var e=this;hg(this.backendName).forEach((function(t){null!=t.setupFunc&&t.setupFunc(e.backendInstance)}))},t.disposeRegisteredKernels=function(e){var t=this;hg(e).forEach((function(n){null!=n.disposeFunc&&n.disposeFunc(t.registry[e])}))},t.initializeBackend=function(e){var t=this,n=this.registryFactory[e];if(null==n)throw new Error("Cannot initialize backend "+e+", no registration found.");try{var r=n.factory();if(!r||r instanceof rv||"function"!=typeof r.then)return this.registry[e]=r,{success:!0,asyncInit:!1};var a=++this.pendingBackendInitId,i=r.then((function(n){return!(a<t.pendingBackendInitId)&&(t.registry[e]=n,t.pendingBackendInit=null,!0)})).catch((function(n){return a<t.pendingBackendInitId||(t.pendingBackendInit=null,console.warn("Initialization of backend "+e+" failed"),console.warn(n.stack||n.message)),!1}));return this.pendingBackendInit=i,{success:i,asyncInit:!0}}catch(t){return console.warn("Initialization of backend "+e+" failed"),console.warn(t.stack||t.message),{success:!1,asyncInit:!1}}},t.removeBackend=function(e){if(!(e in this.registryFactory))throw new Error(e+" backend not found in registry");this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)},t.getSortedBackends=function(){var e=this;if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort((function(t,n){return e.registryFactory[n].priority-e.registryFactory[t].priority}))},t.initializeBackendsAndReturnBest=function(){for(var e=this.getSortedBackends(),t=0;t<e.length;t++){var n=e[t],r=this.initializeBackend(n),a=r.success,i=r.asyncInit;if(i||a)return{name:n,asyncInit:i}}throw new Error("Could not initialize any backends, all backend initializations failed.")},t.moveData=function(e,t){var n=this.state.tensorInfo.get(t),r=n.backend,a=this.readSync(t);r.disposeData(t),n.backend=e,e.move(t,a,n.shape,n.dtype),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++},t.tidy=function(e,t){var n,r=this,a=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");a=e}return this.scopedRun((function(){return r.startScope(a)}),(function(){return r.endScope(n)}),(function(){return(n=t())instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n}))},t.scopedRun=function(e,t,n){e();try{var r=n();return t(),r}catch(e){throw t(),e}},t.nextTensorId=function(){return e.nextTensorId++},t.nextVariableId=function(){return e.nextVariableId++},t.clone=function(e){var t=this.makeTensorFromDataId(e.dataId,e.shape,e.dtype),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(function(e){return{x:function(){var t={x:e},n={dtype:"float32"};return Jg.runKernelFunc((function(t){return t.cast(e,"float32")}),t,null,"Cast",n)}}}),[],{}),t},t.runKernel=function(e,t,n,r,a){return this.runKernelFunc(null,t,null,e,n,r,a)},t.shouldCheckForMemLeaks=function(){return this.ENV.getBool("IS_TEST")},t.checkKernelForMemLeak=function(e,t,n){var r=this.backend.numDataIds(),a=0;n.forEach((function(e){a+="complex64"===e.dtype?3:1}));var i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],o=r-t-a-i;if(o>0)throw new Error("Backend '"+this.backendName+"' has an internal memory leak ("+o+" data ids) after running '"+e+"'")},t.runKernelFunc=function(e,t,n,r,a,i,o){var s,u=this,l=[],c=this.isTapeOn();null==r&&(r=null!=this.state.activeScope?this.state.activeScope.name:"");var p,h=this.state.numBytes,f=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);var d,m,v=cg(r,this.backendName);if(null!=v)p=function(){var e=u.backend.numDataIds();d=v.kernelFunc({inputs:t,attrs:a,backend:u.backend});var n=Array.isArray(d)?d:[d];u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(r,e,n);var s=n.map((function(e){if(null!=e.rank)return e;var t=e.dataId,n=e.shape,r=e.dtype;return u.makeTensorFromDataId(t,n,r)}));if(c){var p=u.getTensorsForGradient(r,t,s);if(null==p){null==o&&(o=[]);var h=s.filter((function(e,t){return o[t]}));p=(i||[]).slice().concat(h)}l=u.saveTensorsForBackwardMode(p)}return s};else{if(null==e)throw new Error("Error running "+r+": Neither modular kernel nor forward func passed");var g=function(e){c&&(l=e.map((function(e){return u.keep(u.clone(e))})))};p=function(){var t=u.backend.numDataIds();d=u.tidy((function(){return e(u.backend,g)}));var n=Array.isArray(d)?d:[d];return u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(r,t,n),n}}return this.scopedRun((function(){return u.state.kernelDepth++}),(function(){return u.state.kernelDepth--}),(function(){u.ENV.getBool("DEBUG")||u.state.profiling?(m=u.profiler.profileKernel(r,t,(function(){return p()})),u.ENV.getBool("DEBUG")&&u.profiler.logKernelProfile(m),s=m.outputs):s=p()})),c&&this.addTapeNode(r,t,s,n,l,a),this.state.profiling&&this.state.activeProfile.kernels.push({name:r,bytesAdded:this.state.numBytes-h,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-f,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(t).map((function(e){return null!=t[e]?t[e].shape:null})),outputShapes:s.map((function(e){return e.shape})),kernelTimeMs:m.timeMs,extraInfo:m.extraInfo}),Array.isArray(d)?s:s[0]},t.saveTensorsForBackwardMode=function(e){var t=this;return e.map((function(e){return t.keep(t.clone(e))}))},t.getTensorsForGradient=function(e,t,n){var r=pg(e);if(null!=r){var a,i=r.inputsToSave||[],o=r.outputsToSave||[];r.saveAllInputs?(lv(Array.isArray(t),(function(){return"saveAllInputs is true, expected inputs to be an array."})),a=Object.keys(t).map((function(e){return t[e]}))):a=i.map((function(e){return t[e]}));var s=n.filter((function(e,t){return o[t]}));return a.concat(s)}return null},t.makeTensor=function(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;var a=e;"string"===n&&Av(e[0])&&(a=e.map((function(e){return xg(e)})));var i=r.write(a,t,n),o=new Fg(t,n,i,this.nextTensorId());if(this.incRef(o,r),"string"===n){var s=this.state.tensorInfo.get(i),u=Rv(a);this.state.numBytes+=u-s.bytes,s.bytes=u}return o},t.makeTensorFromDataId=function(e,t,n,r){var a=new Fg(t,n=n||"float32",e,this.nextTensorId());return this.incRef(a,r),a},t.makeVariable=function(e,t,n,r){void 0===t&&(t=!0),n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));var a=new Pg(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error("Variable with name "+a.name+" was already registered");return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a},t.incRef=function(e,t){var n=this.state.tensorInfo.has(e.dataId)?this.state.tensorInfo.get(e.dataId).refCount:0;if(this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++,0===n){this.state.numDataBuffers++;var r=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(r=e.size*Ev(e.dtype)),this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:r,refCount:0}),this.state.numBytes+=r}this.state.tensorInfo.get(e.dataId).refCount++,e instanceof Pg||this.track(e)},t.disposeTensor=function(e){if(this.state.tensorInfo.has(e.dataId)){this.state.numTensors--,"string"===e.dtype&&this.state.numStringTensors--;var t=this.state.tensorInfo.get(e.dataId);t.refCount<=1?("complex64"!==e.dtype&&(this.state.numBytes-=t.bytes),this.state.numDataBuffers--,t.backend.disposeData(e.dataId),this.state.tensorInfo.delete(e.dataId)):this.state.tensorInfo.get(e.dataId).refCount--}},t.disposeVariables=function(){for(var e in this.state.registeredVariables){var t=this.state.registeredVariables[e];this.disposeVariable(t)}},t.disposeVariable=function(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]},t.memory=function(){var e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e},t.profile=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r,a,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.state.profiling=!0,n=this.state.numBytes,r=this.state.numTensors,this.state.activeProfile.kernels=[],e.next=6,t();case 6:this.state.activeProfile.result=e.sent,this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max.apply(Math,this.state.activeProfile.kernels.map((function(e){return e.totalBytesSnapshot}))),this.state.activeProfile.newBytes=this.state.numBytes-n,this.state.activeProfile.newTensors=this.state.numTensors-r,a=tv(this.state.activeProfile.kernels);case 12:if((i=a()).done){e.next=22;break}return o=i.value,e.next=16,o.kernelTimeMs;case 16:return o.kernelTimeMs=e.sent,e.next=19,o.extraInfo;case 19:o.extraInfo=e.sent;case 20:e.next=12;break;case 22:return e.abrupt("return",this.state.activeProfile);case 23:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.isTapeOn=function(){return this.state.gradientDepth>0&&0===this.state.kernelDepth},t.addTapeNode=function(e,t,n,r,a,i){var o=this,s={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},u=pg(e);null!=u&&(r=u.gradFunc),null!=r&&(s.gradient=function(e){return e=e.map((function(e,t){if(null==e){var r=n[t],a=Bv(r.size,r.dtype);return o.makeTensor(a,r.shape,r.dtype)}return e})),r(e.length>1?e:e[0],a,i)}),this.state.activeTape.push(s)},t.keep=function(e){return e.kept=!0,e},t.startTape=function(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++},t.endTape=function(){this.state.gradientDepth--},t.startScope=function(e){var t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t},t.endScope=function(e){for(var t=this,n=Hg(e),r=new Set(n.map((function(e){return e.id}))),a=0;a<this.state.activeScope.track.length;a++){var i=this.state.activeScope.track[a];i.kept||r.has(i.id)||i.dispose()}var o=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],n.forEach((function(e){e.kept||e.scopeId!==o.id||t.track(e)}))},t.gradients=function(e,t,n,r){var a=this;if(void 0===r&&(r=!1),lv(t.length>0,(function(){return"gradients() received an empty list of xs."})),null!=n&&"float32"!==n.dtype)throw new Error("dy must have 'float32' dtype, but has '"+n.dtype+"'");var i=this.scopedRun((function(){return a.startTape()}),(function(){return a.endTape()}),(function(){return a.tidy("forward",e)}));lv(i instanceof Fg,(function(){return"The result y returned by f() must be a tensor."}));var o=function(e,t,n){for(var r={},a={},i=0;i<t.length;i++)r[t[i].id]=!0;for(var o=0;o<e.length;o++){var s=e[o],u=s.inputs;for(var l in u){for(var c=u[l],p=!1,h=0;h<t.length;h++)if(r[c.id]){s.outputs.forEach((function(e){return r[e.id]=!0})),p=!0,a[s.id]=!0;break}if(p)break}}var f={};f[n.id]=!0;for(var d={},m=e.length-1;m>=0;m--)for(var v=e[m],g=v.inputs,y=0;y<v.outputs.length;y++)if(f[v.outputs[y].id]){for(var b in g)f[g[b].id]=!0,d[v.id]=!0;break}for(var x=[],w=0;w<e.length;w++){var k=e[w];if(a[k.id]&&d[k.id]){var N={};for(var I in k.inputs){var S=k.inputs[I];r[S.id]&&(N[I]=S)}var T=Object.assign({},k);T.inputs=N,T.outputs=k.outputs,x.push(T)}}return x}(this.state.activeTape,t,i);if(!r&&0===o.length&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(function(){var e,r,s={};s[i.id]=null==n?(e=i.shape,r=Pv(fv(e),"float32"),Jg.makeTensor(r,e,"float32")):n,function(e,t,n,r){for(var a=function(a){var i=t[a],o=[];if(i.outputs.forEach((function(t){var n=e[t.id];null!=n?o.push(n):o.push(null)})),null==i.gradient)throw new Error("Cannot compute gradient: gradient function not found for "+i.kernelName+".");var s=i.gradient(o),u=function(t){if(!(t in s))throw new Error("Cannot backprop through input "+t+". Available gradients found: "+Object.keys(s)+".");var a=n((function(){return s[t]()}));if("float32"!==a.dtype)throw new Error("Error in gradient for op "+i.kernelName+". The gradient of input "+t+" must have 'float32' dtype, but has '"+a.dtype+"'");var o=i.inputs[t];if(!dv(a.shape,o.shape))throw new Error("Error in gradient for op "+i.kernelName+". The gradient of input '"+t+"' has shape '"+a.shape+"', which does not match the shape of the input '"+o.shape+"'");if(null==e[o.id])e[o.id]=a;else{var u=e[o.id];e[o.id]=r(u,a),u.dispose()}};for(var l in i.inputs)u(l)},i=t.length-1;i>=0;i--)a(i)}(s,o,(function(e){return a.tidy(e)}),Zg);var u=t.map((function(e){return s[e.id]}));return 0===a.state.gradientDepth&&(a.state.activeTape.forEach((function(e){for(var t,n=tv(e.saved);!(t=n()).done;){t.value.dispose()}})),a.state.activeTape=null),{value:i,grads:u}}))},t.customGrad=function(e){var t=this;return lv(Ov(e),(function(){return"The f passed in customGrad(f) must be a function."})),function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];var i;lv(r.every((function(e){return e instanceof Fg})),(function(){return"The args passed in customGrad(f)(x1, x2,...) must all be tensors"}));var o={};return r.forEach((function(e,t){o[t]=e})),t.runKernelFunc((function(t,n){return lv((i=e.apply(void 0,[].concat(r,[n]))).value instanceof Fg,(function(){return"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor"})),lv(Ov(i.gradFunc),(function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function."})),i.value}),o,(function(e,t){var n=i.gradFunc(e,t),a=Array.isArray(n)?n:[n];lv(a.length===r.length,(function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...)."})),lv(a.every((function(e){return e instanceof Fg})),(function(){return"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."}));var o={};return a.forEach((function(e,t){o[t]=function(){return e}})),o}))}},t.readSync=function(e){return this.state.tensorInfo.get(e).backend.readSync(e)},t.read=function(e){return this.state.tensorInfo.get(e).backend.read(e)},t.time=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=yg(),e.next=3,this.backend.time(t);case 3:return(r=e.sent).wallMs=yg()-n,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.track=function(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e},t.reset=function(){for(var e in this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new Kg,this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null},Hm(e,[{key:"backend",get:function(){if(null!=this.pendingBackendInit)throw new Error("Backend '"+this.backendName+"' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");if(null==this.backendInstance){var e=this.initializeBackendsAndReturnBest(),t=e.name;if(e.asyncInit)throw new Error("The highest priority backend '"+t+"' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");this.setBackend(t)}return this.backendInstance}},{key:"registeredVariables",get:function(){return this.state.registeredVariables}}]),e}();function Yg(){var t=Yv();if(null==t._tfengine){var n=new qv(t);t._tfengine=new Xg(n)}return function(t){e.ENV=t}(t._tfengine.ENV),Ag=function(){return t._tfengine},t._tfengine}Xg.nextTensorId=0,Xg.nextVariableId=0;var Jg=Yg();function Zg(e,t){var n={a:e,b:t};return Jg.runKernel(Zv,n)}function Qg(){if("undefined"!=typeof navigator&&null!=navigator){var e=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4))}return!1}function $g(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}var ey={__proto__:null,isMobile:Qg,isBrowser:$g},ty=Xv();function ny(e,t){var n=e;if(Cv(e))return"string"===t?[]:[e.length];if(!Array.isArray(e))return[];for(var r=[];Array.isArray(n)||Cv(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&Xv().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&function e(t,n,r){if(r=r||[],!Array.isArray(t)&&!Cv(t))return void lv(0===n.length,(function(){return"Element arr["+r.join("][")+"] is a primitive, but should be an array/TypedArray of "+n[0]+" elements"}));lv(n.length>0,(function(){return"Element arr["+r.join("][")+"] should be a primitive, but is an array of "+t.length+" elements"})),lv(t.length===n[0],(function(){return"Element arr["+r.join("][")+"] should have "+n[0]+" elements, but has "+t.length+" elements"}));for(var a=n.slice(1),i=0;i<t.length;++i)e(t[i],a,r.concat(i))}(e,r,[]),r}function ry(e,t,n,r){if(null!=e&&("numeric"!==e&&e!==t||"numeric"===e&&"string"===t))throw new Error("Argument '"+n+"' passed to '"+r+"' must be "+e+" tensor, but got "+t+" tensor")}function ay(e,t,n,r){if(void 0===r&&(r="numeric"),e instanceof Fg)return ry(r,e.dtype,t,n),e;var a=_v(e);if("string"!==a&&["bool","int32","float32"].indexOf(r)>=0&&(a=r),ry(r,a,t,n),null==e||!Cv(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){var i=null==e?"null":e.constructor.name;throw new Error("Argument '"+t+"' passed to '"+n+"' must be a Tensor or TensorLike, but got '"+i+"'")}var o=ny(e,a);Cv(e)||Array.isArray(e)||(e=[e]);var s="string"!==a?gg(e,a):hv(e,[],!0);return Jg.makeTensor(s,o,a)}function iy(e,t,n,r){if(void 0===r&&(r="numeric"),!Array.isArray(e))throw new Error("Argument "+t+" passed to "+n+" must be a `Tensor[]` or `TensorLike[]`");return e.map((function(e,r){return ay(e,t+"["+r+"]",n)}),r)}ty.registerFlag("DEBUG",(function(){return!1}),(function(e){e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),ty.registerFlag("IS_BROWSER",(function(){return $g()})),ty.registerFlag("IS_NODE",(function(){return"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node})),ty.registerFlag("IS_CHROME",(function(){return"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)})),ty.registerFlag("PROD",(function(){return!1})),ty.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(function(){return ty.getBool("DEBUG")})),ty.registerFlag("DEPRECATION_WARNINGS_ENABLED",(function(){return!0})),ty.registerFlag("IS_TEST",(function(){return!1})),ty.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(function(){return!0}));function oy(e){var t=Object.keys(e);if(1!==t.length)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+t.length+" keys.");var n=t[0],r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+="__op";var a=function(){Jg.startScope(n);try{var e=r.apply(void 0,arguments);return jv(e)&&console.error("Cannot return a Promise inside of tidy."),Jg.endScope(e),e}catch(e){throw Jg.endScope(null),e}};return Object.defineProperty(a,"name",{value:n,configurable:!0}),a}var sy=oy({complex_:function(e,t){var n=ay(e,"real","complex"),r=ay(t,"imag","complex");cv(n.shape,r.shape,"real and imag shapes, "+n.shape+" and "+r.shape+", must match in call to tf.complex().");var a={real:n,imag:r};return Jg.runKernel("Complex",a)}});function uy(e,t,n,r){if(null==r&&(r=_v(e)),"complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!Cv(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=t){Vv(t);var a=fv(t),i=fv(n);lv(a===i,(function(){return"Based on the provided shape, ["+t+"], the tensor should have "+a+" values but has "+i}));for(var o=0;o<n.length;++o){var s=n[o],u=o!==n.length-1||s!==fv(t.slice(o));lv(n[o]===t[o]||!u,(function(){return"Error creating a new Tensor. Inferred shape ("+n+") does not match the provided shape ("+t+"). "}))}}return Cv(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?gg(e,r):hv(e,[],!0),Jg.makeTensor(e,t,r)}function ly(e,t,n){return uy(e,t,ny(e,n),n)}var cy={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8};function py(e,t){return hy.apply(this,arguments)}function hy(){return(hy=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i,o,s,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r=[],a=[],i=Array.isArray(t)?t.map((function(e){return e.name})):Object.keys(t),o=function(e){var o=i[e],s=Array.isArray(t)?t[e].tensor:t[o];if("float32"!==s.dtype&&"int32"!==s.dtype&&"bool"!==s.dtype&&"string"!==s.dtype&&"complex64"!==s.dtype)throw new Error("Unsupported dtype in weight '"+o+"': "+s.dtype);var u={name:o,shape:s.shape,dtype:s.dtype};if("string"===s.dtype){var l=new Promise(function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r,a,i,o,u,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.bytes();case 2:for(n=e.sent,r=n.reduce((function(e,t){return e+t.length}),0)+4*n.length,a=new Uint8Array(r),i=0,o=0;o<n.length;o++)u=n[o],l=new Uint8Array(new Uint32Array([u.length]).buffer),a.set(l,i),i+=4,a.set(u,i),i+=u.length;t(a);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());a.push(l)}else a.push(s.data());null!=n&&(u.group=n),r.push(u)},s=0;s<i.length;++s)o(s);return e.next=7,Promise.all(a);case 7:return u=e.sent,e.abrupt("return",{data:dy(u),specs:r});case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fy(e,t){for(var n,r,a={},i=0,o=tv(t);!(r=o()).done;){var s=r.value,u=s.name,l=s.dtype,c=s.shape,p=fv(c),h=void 0;if("quantization"in s){var f=s.quantization;if("uint8"===f.dtype||"uint16"===f.dtype){if(!("min"in f)||!("scale"in f))throw new Error("Weight "+s.name+" with quantization "+f.dtype+" doesn't have corresponding metadata min and scale.")}else{if("float16"!==f.dtype)throw new Error("Weight "+s.name+" has unknown quantization dtype "+f.dtype+". Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.");if("float32"!==l)throw new Error("Weight "+s.name+" is quantized with "+f.dtype+" which only supports weights of type float32 not "+l+".")}var d=cy[f.dtype],m=e.slice(i,i+p*d),v="uint8"===f.dtype?new Uint8Array(m):new Uint16Array(m);if("float32"===l)if("uint8"===f.dtype||"uint16"===f.dtype){h=new Float32Array(v.length);for(var g=0;g<v.length;g++){var y=v[g];h[g]=y*f.scale+f.min}}else{if("float16"!==f.dtype)throw new Error("Unsupported quantization type "+f.dtype+" for weight type float32.");void 0===n&&(n=ky()),h=n(v)}else{if("int32"!==l)throw new Error("Unsupported dtype in weight '"+u+"': "+l);if("uint8"!==f.dtype&&"uint16"!==f.dtype)throw new Error("Unsupported quantization type "+f.dtype+" for weight type int32.");h=new Int32Array(v.length);for(var b=0;b<v.length;b++){var x=v[b];h[b]=Math.round(x*f.scale+f.min)}}i+=p*d}else if("string"===l){var w=fv(s.shape);h=[];for(var k=0;k<w;k++){var N=new Uint32Array(e.slice(i,i+4))[0];i+=4;var I=new Uint8Array(e.slice(i,i+N));h.push(I),i+=N}}else{var S=cy[l],T=e.slice(i,i+p*S);if("float32"===l)h=new Float32Array(T);else if("int32"===l)h=new Int32Array(T);else if("bool"===l)h=new Uint8Array(T);else{if("complex64"!==l)throw new Error("Unsupported dtype in weight '"+u+"': "+l);h=new Float32Array(T);for(var C=new Float32Array(h.length/2),E=new Float32Array(h.length/2),R=0;R<C.length;R++)C[R]=h[2*R],E[R]=h[2*R+1];var A=ly(C,c,"float32"),D=ly(E,c,"float32");a[u]=sy(A,D),A.dispose(),D.dispose()}i+=p*S}"complex64"!==l&&(a[u]=ly(h,c,l))}return a}function dy(e){if(null===e)throw new Error("Invalid input value: "+JSON.stringify(e));var t=0,n=[];e.forEach((function(e){if(t+=e.byteLength,n.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw new Error("Unsupported TypedArray subtype: "+e.constructor.name)}));var r=new Uint8Array(t),a=0;return n.forEach((function(e){r.set(new Uint8Array(e.buffer),a),a+=e.byteLength})),r.buffer}var my="undefined"!=typeof Buffer&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function vy(e){return my?Buffer.byteLength(e):new Blob([e]).size}function gy(e){if(my)return Buffer.from(e).toString("base64");for(var t=new Uint8Array(e),n="",r=0,a=t.length;r<a;r++)n+=String.fromCharCode(t[r]);return btoa(n)}function yy(e){if(my){var t=Buffer.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}for(var n=atob(e),r=new Uint8Array(n.length),a=0;a<n.length;++a)r.set([n.charCodeAt(a)],a);return r.buffer}function by(e){if(1===e.length)return e[0];var t=0;e.forEach((function(e){t+=e.byteLength}));var n=new Uint8Array(t),r=0;return e.forEach((function(e){n.set(new Uint8Array(e),r),r+=e.byteLength})),n.buffer}function xy(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);var t=e.split("/");return t[t.length-1]}function wy(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:vy(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:vy(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}function ky(){var e=function(){var e=function(e){for(var t=e<<13,n=0;0==(8388608&t);)n-=8388608,t<<=1;return(t&=-8388609)|(n+=947912704)},t=new Uint32Array(2048);t[0]=0;for(var n=1;n<1024;n++)t[n]=e(n);for(var r=1024;r<2048;r++)t[r]=939524096+(r-1024<<13);return t}(),t=function(){var e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(var t=1;t<31;t++)e[t]=t<<23;for(var n=33;n<63;n++)e[n]=2147483648+(n-32<<23);return e}(),n=function(){for(var e=new Uint32Array(64),t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return function(r){for(var a=new ArrayBuffer(4*r.length),i=new Uint32Array(a),o=0;o<r.length;o++){var s=r[o],u=e[n[s>>10]+(1023&s)]+t[s>>10];i[o]=u}return new Float32Array(a)}}var Ny=function(){function e(){this.saveRouters=[],this.loadRouters=[]}return e.getInstance=function(){return null==e.instance&&(e.instance=new e),e.instance},e.registerSaveRouter=function(t){e.getInstance().saveRouters.push(t)},e.registerLoadRouter=function(t){e.getInstance().loadRouters.push(t)},e.getSaveHandlers=function(t){return e.getHandlers(t,"save")},e.getLoadHandlers=function(t,n){return e.getHandlers(t,"load",n)},e.getHandlers=function(t,n,r){var a=[];return("load"===n?e.getInstance().loadRouters:e.getInstance().saveRouters).forEach((function(e){var n=e(t,r);null!==n&&a.push(n)})),a},e}(),Iy=function(e){return Ny.getSaveHandlers(e)},Sy=function(e,t){return Ny.getLoadHandlers(e,t)};function Ty(){if(!Xv().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");var e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function Cy(e){var t=e.result;t.createObjectStore("models_store",{keyPath:"modelPath"}),t.createObjectStore("model_info_store",{keyPath:"modelPath"})}var Ey=function(){function e(e){if(this.indexedDB=Ty(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}var t=e.prototype;return t.save=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t.modelTopology instanceof ArrayBuffer)){e.next=2;break}throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");case 2:return e.abrupt("return",this.databaseAction(this.modelPath,t));case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.load=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.databaseAction(this.modelPath));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.databaseAction=function(e,t){var n=this;return new Promise((function(e,r){var a=n.indexedDB.open("tensorflowjs",1);a.onupgradeneeded=function(){return Cy(a)},a.onsuccess=function(){var i=a.result;if(null==t){var o=i.transaction("models_store","readonly"),s=o.objectStore("models_store").get(n.modelPath);s.onsuccess=function(){if(null==s.result)return i.close(),r(new Error("Cannot find model with path '"+n.modelPath+"' in IndexedDB."));e(s.result.modelArtifacts)},s.onerror=function(e){return i.close(),r(s.error)},o.oncomplete=function(){return i.close()}}else{var u,l=wy(t),c=i.transaction("model_info_store","readwrite"),p=c.objectStore("model_info_store"),h=p.put({modelPath:n.modelPath,modelArtifactsInfo:l});h.onsuccess=function(){var a=(u=i.transaction("models_store","readwrite")).objectStore("models_store").put({modelPath:n.modelPath,modelArtifacts:t,modelArtifactsInfo:l});a.onsuccess=function(){return e({modelArtifactsInfo:l})},a.onerror=function(e){var t=(p=c.objectStore("model_info_store")).delete(n.modelPath);t.onsuccess=function(){return i.close(),r(a.error)},t.onerror=function(e){return i.close(),r(a.error)}}},h.onerror=function(e){return i.close(),r(h.error)},c.oncomplete=function(){null==u?i.close():u.oncomplete=function(){return i.close()}}}},a.onerror=function(e){return r(a.error)}}))},e}();Ey.URL_SCHEME="indexeddb://";var Ry=function(e){return Xv().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ey.URL_SCHEME)?(t=e.slice(Ey.URL_SCHEME.length),new Ey(t)):null;var t};function Ay(e){return e.startsWith(Ey.URL_SCHEME)?e.slice(Ey.URL_SCHEME.length):e}Ny.registerSaveRouter(Ry),Ny.registerLoadRouter(Ry);var Dy=function(){function e(){this.indexedDB=Ty()}var t=e.prototype;return t.listModels=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){var r=t.indexedDB.open("tensorflowjs",1);r.onupgradeneeded=function(){return Cy(r)},r.onsuccess=function(){var t=r.result,a=t.transaction("model_info_store","readonly"),i=a.objectStore("model_info_store").getAll();i.onsuccess=function(){for(var t,n={},r=tv(i.result);!(t=r()).done;){var a=t.value;n[a.modelPath]=a.modelArtifactsInfo}e(n)},i.onerror=function(e){return t.close(),n(i.error)},a.oncomplete=function(){return t.close()}},r.onerror=function(e){return n(r.error)}})));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),t.removeModel=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Ay(t),e.abrupt("return",new Promise((function(e,r){var a=n.indexedDB.open("tensorflowjs",1);a.onupgradeneeded=function(){return Cy(a)},a.onsuccess=function(){var n,i=a.result,o=i.transaction("model_info_store","readwrite"),s=o.objectStore("model_info_store"),u=s.get(t);u.onsuccess=function(){if(null==u.result)return i.close(),r(new Error("Cannot find model with path '"+t+"' in IndexedDB."));var a=s.delete(t),o=function(){var a=(n=i.transaction("models_store","readwrite")).objectStore("models_store").delete(t);a.onsuccess=function(){return e(u.result.modelArtifactsInfo)},a.onerror=function(e){return r(u.error)}};a.onsuccess=o,a.onerror=function(e){return o(),i.close(),r(u.error)}},u.onerror=function(e){return i.close(),r(u.error)},o.oncomplete=function(){null==n?i.close():n.oncomplete=function(){return i.close()}}},a.onerror=function(e){return r(a.error)}})));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e}(),Fy="tensorflowjs_models",_y="info",Oy="model_topology",My="weight_specs",Ly="weight_data",zy="model_metadata";function Py(e){return{info:[Fy,e,_y].join("/"),topology:[Fy,e,Oy].join("/"),weightSpecs:[Fy,e,My].join("/"),weightData:[Fy,e,Ly].join("/"),modelMetadata:[Fy,e,zy].join("/")}}function By(e){var t=e.split("/");if(t.length<3)throw new Error("Invalid key format: "+e);return t.slice(1,t.length-1).join("/")}function Wy(e){return e.startsWith(Vy.URL_SCHEME)?e.slice(Vy.URL_SCHEME.length):e}var Vy=function(){function e(e){if(!Xv().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=Py(this.modelPath)}var t=e.prototype;return t.save=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t.modelTopology instanceof ArrayBuffer)){e.next=4;break}throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");case 4:return n=JSON.stringify(t.modelTopology),r=JSON.stringify(t.weightSpecs),a=wy(t),e.prev=7,this.LS.setItem(this.keys.info,JSON.stringify(a)),this.LS.setItem(this.keys.topology,n),this.LS.setItem(this.keys.weightSpecs,r),this.LS.setItem(this.keys.weightData,gy(t.weightData)),i={format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy},null!=t.signature&&(i.signature=t.signature),null!=t.userDefinedMetadata&&(i.userDefinedMetadata=t.userDefinedMetadata),null!=t.modelInitializer&&(i.modelInitializer=t.modelInitializer),this.LS.setItem(this.keys.modelMetadata,JSON.stringify(i)),e.abrupt("return",{modelArtifactsInfo:a});case 20:throw e.prev=20,e.t0=e.catch(7),this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error("Failed to save model '"+this.modelPath+"' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes="+a.modelTopologyBytes+", weightSpecsBytes="+a.weightSpecsBytes+", weightDataBytes="+a.weightDataBytes+".");case 28:case"end":return e.stop()}}),e,this,[[7,20]])})));return function(t){return e.apply(this,arguments)}}(),t.load=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a,i,o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(t=JSON.parse(this.LS.getItem(this.keys.info)))){e.next=3;break}throw new Error("In local storage, there is no model with name '"+this.modelPath+"'");case 3:if("JSON"===t.modelTopologyType){e.next=5;break}throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");case 5:if(n={},null!=(r=JSON.parse(this.LS.getItem(this.keys.topology)))){e.next=9;break}throw new Error("In local storage, the topology of model '"+this.modelPath+"' is missing.");case 9:if(n.modelTopology=r,null!=(a=JSON.parse(this.LS.getItem(this.keys.weightSpecs)))){e.next=13;break}throw new Error("In local storage, the weight specs of model '"+this.modelPath+"' are missing.");case 13:if(n.weightSpecs=a,null!=(i=this.LS.getItem(this.keys.modelMetadata))&&(o=JSON.parse(i),n.format=o.format,n.generatedBy=o.generatedBy,n.convertedBy=o.convertedBy,null!=o.signature&&(n.signature=o.signature),null!=o.userDefinedMetadata&&(n.userDefinedMetadata=o.userDefinedMetadata),null!=o.modelInitializer&&(n.modelInitializer=o.modelInitializer)),null!=(s=this.LS.getItem(this.keys.weightData))){e.next=19;break}throw new Error("In local storage, the binary weight values of model '"+this.modelPath+"' are missing.");case 19:return n.weightData=yy(s),e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}();Vy.URL_SCHEME="localstorage://";var Uy=function(e){return Xv().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Vy.URL_SCHEME)?(t=e.slice(Vy.URL_SCHEME.length),new Vy(t)):null;var t};Ny.registerSaveRouter(Uy),Ny.registerLoadRouter(Uy);var Gy=function(){function e(){lv(Xv().getBool("IS_BROWSER"),(function(){return"Current environment is not a web browser"})),lv("undefined"==typeof window||void 0!==window.localStorage,(function(){return"Current browser does not appear to support localStorage"})),this.LS=window.localStorage}var t=e.prototype;return t.listModels=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t={},n=Fy+"/",r="/"+_y,a=0;a<this.LS.length;++a)(i=this.LS.key(a)).startsWith(n)&&i.endsWith(r)&&(o=By(i),t[o]=JSON.parse(this.LS.getItem(i)));return e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.removeModel=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=Wy(t),n=Py(t),null!=this.LS.getItem(n.info)){e.next=4;break}throw new Error("Cannot find model at path '"+t+"'");case 4:return r=JSON.parse(this.LS.getItem(n.info)),this.LS.removeItem(n.info),this.LS.removeItem(n.topology),this.LS.removeItem(n.weightSpecs),this.LS.removeItem(n.weightData),e.abrupt("return",r);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}(),jy=function(){function e(){this.managers={}}return e.getInstance=function(){return null==e.instance&&(e.instance=new e),e.instance},e.registerManager=function(t,n){lv(null!=t,(function(){return"scheme must not be undefined or null."})),t.endsWith("://")&&(t=t.slice(0,t.indexOf("://"))),lv(t.length>0,(function(){return"scheme must not be an empty string."}));var r=e.getInstance();lv(null==r.managers[t],(function(){return"A model store manager is already registered for scheme '"+t+"'."})),r.managers[t]=n},e.getManager=function(e){var t=this.getInstance().managers[e];if(null==t)throw new Error("Cannot find model manager for scheme '"+e+"'");return t},e.getSchemes=function(){return Object.keys(this.getInstance().managers)},e}();function Hy(e){if(-1===e.indexOf("://"))throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+jy.getSchemes().join(","));return{scheme:e.split("://")[0],path:e.split("://")[1]}}function qy(e,t,n){return Ky.apply(this,arguments)}function Ky(){return(Ky=Gm(regeneratorRuntime.mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r=!1),lv(t!==n,(function(){return"Old path and new path are the same: '"+t+"'"})),lv((a=Ny.getLoadHandlers(t)).length>0,(function(){return"Copying failed because no load handler is found for source URL "+t+"."})),lv(a.length<2,(function(){return"Copying failed because more than one ("+a.length+") load handlers for source URL "+t+"."})),i=a[0],lv((o=Ny.getSaveHandlers(n)).length>0,(function(){return"Copying failed because no save handler is found for destination URL "+n+"."})),lv(o.length<2,(function(){return"Copying failed because more than one ("+a.length+") save handlers for destination URL "+n+"."})),s=o[0],u=Hy(t).scheme,l=Hy(t).path,c=u===Hy(t).scheme,e.next=15,i.load();case 15:if(p=e.sent,!r||!c){e.next=19;break}return e.next=19,jy.getManager(u).removeModel(l);case 19:return e.next=21,s.save(p);case 21:if(h=e.sent,!r||c){e.next=25;break}return e.next=25,jy.getManager(u).removeModel(l);case 25:return e.abrupt("return",h.modelArtifactsInfo);case 26:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Xy(){return(Xy=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a,i,o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=jy.getSchemes(),n={},r=tv(t);case 3:if((a=r()).done){e.next=11;break}return i=a.value,e.next=7,jy.getManager(i).listModels();case 7:for(s in o=e.sent)n[i+"://"+s]=o[s];case 9:e.next=3;break;case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Yy(){return(Yy=Gm(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Hy(t),r=jy.getManager(n.scheme),e.abrupt("return",r.removeModel(n.path));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Jy(){return(Jy=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return!1,e.abrupt("return",qy(t,n,!1));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Zy(){return(Zy=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return!0,e.abrupt("return",qy(t,n,!0));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Qy=function(){function e(){}var t=e.prototype;return t.fetch=function(e){function t(t,n){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,t){return fetch(e,t)})),t.now=function(){return performance.now()},t.encode=function(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error("Browser's encoder only supports utf-8, but got "+t);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)},t.decode=function(e,t){return new TextDecoder(t).decode(e)},e}();if(Xv().get("IS_BROWSER")){Xv().setPlatform("browser",new Qy);try{jy.registerManager(Vy.URL_SCHEME,new Gy)}catch(e){}try{jy.registerManager(Ey.URL_SCHEME,new Dy)}catch(e){}}var $y,eb=function(){return require("node-fetch")};var tb=function(){function e(){this.util=require("util"),this.textEncoder=new this.util.TextEncoder}var t=e.prototype;return t.fetch=function(e,t){return null!=Xv().global.fetch?Xv().global.fetch(e,t):(null==$y&&($y=eb()),$y(e,t))},t.now=function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6},t.encode=function(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error("Node built-in encoder only supports utf-8, but got "+t);return this.textEncoder.encode(e)},t.decode=function(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)},e}();function nb(e,t,n){return void 0===t&&(t="float32"),t=t||"float32",Vv(e),new Rg(e,t,n)}Xv().get("IS_NODE")&&Xv().setPlatform("node",new tb);var rb=oy({cast_:function(e,t){var n=ay(e,"x","cast");if(!Sv(t))throw new Error("Failed to cast to unknown dtype "+t);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");var r={x:n},a={dtype:t};return Jg.runKernel("Cast",r,a)}});var ab=oy({clone_:function(e){var t={x:ay(e,"x","clone",null)};return Jg.runKernel("Identity",t)}});function ib(e,t){void 0===t&&(t=!1),console.log(e.toString(t))}Yg(),Dg={buffer:nb,cast:rb,clone:ab,print:ib};function ob(e){return new Promise((function(e){return setTimeout(e)})).then(e)}var sb=function(){function e(t){if(!Xv().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");t.startsWith(e.URL_SCHEME)&&(t=t.slice(e.URL_SCHEME.length)),null!=t&&0!==t.length||(t="model"),this.modelTopologyFileName=t+".json",this.weightDataFileName=t+".weights.bin"}return e.prototype.save=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r,a,i,o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"!=typeof document){e.next=2;break}throw new Error("Browser downloads are not supported in this environment since `document` is not present");case 2:if(n=window.URL.createObjectURL(new Blob([t.weightData],{type:"application/octet-stream"})),!(t.modelTopology instanceof ArrayBuffer)){e.next=7;break}throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");case 7:return r=[{paths:["./"+this.weightDataFileName],weights:t.weightSpecs}],a={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,weightsManifest:r},null!=t.signature&&(a.signature=t.signature),null!=t.userDefinedMetadata&&(a.userDefinedMetadata=t.userDefinedMetadata),null!=t.modelInitializer&&(a.modelInitializer=t.modelInitializer),i=window.URL.createObjectURL(new Blob([JSON.stringify(a)],{type:"application/json"})),(o=null==this.jsonAnchor?document.createElement("a"):this.jsonAnchor).download=this.modelTopologyFileName,o.href=i,e.next=18,ob((function(){return o.dispatchEvent(new MouseEvent("click"))}));case 18:if(null==t.weightData){e.next=24;break}return(s=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor).download=this.weightDataFileName,s.href=n,e.next=24,ob((function(){return s.dispatchEvent(new MouseEvent("click"))}));case 24:return e.abrupt("return",{modelArtifactsInfo:wy(t)});case 25:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}();sb.URL_SCHEME="downloads://";var ub=function(){function e(e){if(null==e||e.length<1)throw new Error("When calling browserFiles, at least 1 file is required, but received "+e);this.files=e}var t=e.prototype;return t.load=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.files[0],n=this.files.slice(1),e.abrupt("return",new Promise((function(e,a){var i=new FileReader;i.onload=function(i){var o=JSON.parse(i.target.result),s=o.modelTopology;if(null!=s){0===n.length&&e({modelTopology:s});var u=o.weightsManifest;if(null!=u){var l;try{l=r.checkManifestAndWeightFiles(u,n)}catch(e){return void a(e)}var c=[],p=[],h=[];u.forEach((function(e){e.paths.forEach((function(e){p.push(e),h.push(null)})),c.push.apply(c,e.weights)})),u.forEach((function(t){t.paths.forEach((function(t){var n=new FileReader;n.onload=function(n){var r=n.target.result,a=p.indexOf(t);if(h[a]=r,-1===h.indexOf(null)){var i={modelTopology:s,weightSpecs:c,weightData:by(h),format:o.format,generatedBy:o.generatedBy,convertedBy:o.convertedBy};null!=o.signature&&(i.signature=o.signature),null!=o.userDefinedMetadata&&(i.userDefinedMetadata=o.userDefinedMetadata),null!=o.modelInitializer&&(i.modelInitializer=o.modelInitializer),e(i)}},n.onerror=function(e){return a("Failed to weights data from file of path '"+t+"'.")},n.readAsArrayBuffer(l[t])}))}))}else a(new Error("weightManifest field is missing from file "+t.name))}else a(new Error("modelTopology field is missing from file "+t.name))},i.onerror=function(e){return a("Failed to read model topology and weights manifest JSON from file '"+t.name+"'. BrowserFiles supports loading Keras-style tf.Model artifacts only.")},i.readAsText(t)})));case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.checkManifestAndWeightFiles=function(e,t){for(var n,r=[],a=t.map((function(e){return xy(e.name)})),i={},o=tv(e);!(n=o()).done;){n.value.paths.forEach((function(e){var n=xy(e);if(-1!==r.indexOf(n))throw new Error("Duplicate file basename found in weights manifest: '"+n+"'");if(r.push(n),-1===a.indexOf(n))throw new Error("Weight file with basename '"+n+"' is not provided.");i[e]=t[a.indexOf(n)]}))}if(r.length!==t.length)throw new Error("Mismatch in the number of files in weights manifest ("+r.length+") and the number of weight files provided ("+t.length+").");return i},e}();function lb(e,t,n,r){!function(e){lv(null!=e&&Array.isArray(e)&&e.length>0,(function(){return"promises must be a none empty array"}))}(e),function(e,t){lv(e>=0&&e<=1,(function(){return"Progress fraction must be in range [0, 1], but got startFraction "+e})),lv(t>=0&&t<=1,(function(){return"Progress fraction must be in range [0, 1], but got endFraction "+t})),lv(t>=e,(function(){return"startFraction must be no more than endFraction, but got startFraction "+e+" and endFraction "+t}))}(n=null==n?0:n,r=null==r?1:r);var a=0;return Promise.all(e.map((function(i){return i.then((function(i){var o=n+ ++a/e.length*(r-n);return t(o),i})),i})))}function cb(e,t){return pb.apply(this,arguments)}function pb(){return(pb=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i,o,s,u,l,c,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n&&(n={}),r=null==n.fetchFunc?Xv().platform.fetch:n.fetchFunc,a=t.map((function(e){return r(e,n.requestInit,{isBinary:!0})})),i=0,o=.5,null!=n.onProgress){e.next=11;break}return e.next=8,Promise.all(a);case 8:e.t0=e.sent,e.next=14;break;case 11:return e.next=13,lb(a,n.onProgress,i,o);case 13:e.t0=e.sent;case 14:if(s=e.t0,u=s.map((function(e){return e.arrayBuffer()})),l=.5,c=1,null!=n.onProgress){e.next=24;break}return e.next=21,Promise.all(u);case 21:e.t1=e.sent,e.next=27;break;case 24:return e.next=26,lb(u,n.onProgress,l,c);case 26:e.t1=e.sent;case 27:return p=e.t1,e.abrupt("return",p);case 29:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function hb(e,t,n,r){return fb.apply(this,arguments)}function fb(){return(fb=Gm(regeneratorRuntime.mark((function e(t,n,r,a){var i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===n&&(n=""),i=db((function(e){return cb(e,{requestInit:a})})),e.abrupt("return",i(t,n,r));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function db(e){return function(){var t=Gm(regeneratorRuntime.mark((function t(n,r,a){var i,o,s,u,l,c,p,h,f,d;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r=""),i=n.map((function(){return!1})),o={},s=null!=a?a.map((function(){return!1})):[],u=[],n.forEach((function(e,t){var n=0;e.weights.forEach((function(e){var r="quantization"in e?e.quantization.dtype:e.dtype,l=cy[r]*fv(e.shape),c=function(){i[t]=!0,null==o[t]&&(o[t]=[]),o[t].push({manifestEntry:e,groupOffset:n,sizeBytes:l})};null!=a?a.forEach((function(t,n){t===e.name&&(c(),s[n]=!0)})):c(),u.push(e.name),n+=l}))})),s.every((function(e){return e}))){t.next=9;break}throw l=a.filter((function(e,t){return!s[t]})),new Error("Could not find weights in manifest with names: "+l.join(", ")+". \nManifest JSON has weights with names: "+u.join(", ")+".");case 9:return c=i.reduce((function(e,t,n){return t&&e.push(n),e}),[]),p=[],c.forEach((function(e){n[e].paths.forEach((function(e){var t=r+(r.endsWith("/")?"":"/")+e;p.push(t)}))})),t.next=14,e(p);case 14:return h=t.sent,f={},d=0,c.forEach((function(e){for(var t=n[e].paths.length,r=0,a=0;a<t;a++)r+=h[d+a].byteLength;for(var i=new ArrayBuffer(r),s=new Uint8Array(i),u=0,l=0;l<t;l++){var c=new Uint8Array(h[d+l]);s.set(c,u),u+=c.byteLength}o[e].forEach((function(e){var t=fy(i.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(var n in t)f[n]=t[n]})),d+=t})),t.abrupt("return",f);case 19:case"end":return t.stop()}}),t)})));return function(e,n,r){return t.apply(this,arguments)}}()}Ny.registerSaveRouter((function(e){return Xv().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(sb.URL_SCHEME)?function(e){void 0===e&&(e="model");return new sb(e)}(e.slice(sb.URL_SCHEME.length)):null}));var mb=function(){function e(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?(lv("function"==typeof t.fetchFunc,(function(){return"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"})),this.fetch=t.fetchFunc):this.fetch=Xv().platform.fetch,lv(null!=e&&e.length>0,(function(){return"URL path for http must not be null, undefined or empty."})),Array.isArray(e)&&lv(2===e.length,(function(){return"URL paths for http must have a length of 2, (actual length is "+e.length+")."})),this.path=e,null!=t.requestInit&&null!=t.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}var t=e.prototype;return t.save=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t.modelTopology instanceof ArrayBuffer)){e.next=2;break}throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");case 2:return(n=Object.assign({method:this.DEFAULT_METHOD},this.requestInit)).body=new FormData,r=[{paths:["./model.weights.bin"],weights:t.weightSpecs}],a={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,weightsManifest:r},null!=t.signature&&(a.signature=t.signature),null!=t.userDefinedMetadata&&(a.userDefinedMetadata=t.userDefinedMetadata),null!=t.modelInitializer&&(a.modelInitializer=t.modelInitializer),n.body.append("model.json",new Blob([JSON.stringify(a)],{type:"application/json"}),"model.json"),null!=t.weightData&&n.body.append("model.weights.bin",new Blob([t.weightData],{type:"application/octet-stream"}),"model.weights.bin"),e.next=13,this.fetch(this.path,n);case 13:if(!(i=e.sent).ok){e.next=18;break}return e.abrupt("return",{modelArtifactsInfo:wy(t),responses:[i]});case 18:throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+i.status+".");case 19:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.load=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a,i,o,s,u,l,c,p,h,f,d,m;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.fetch(this.path,this.requestInit);case 2:if((t=e.sent).ok){e.next=5;break}throw new Error("Request to "+this.path+" failed with status code "+t.status+". Please verify this URL points to the model JSON of the model to load.");case 5:return e.prev=5,e.next=8,t.json();case 8:n=e.sent,e.next=16;break;case 11:throw e.prev=11,e.t0=e.catch(5),r="Failed to parse model JSON of response from "+this.path+".",this.path.endsWith(".pb")?r+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":r+=" Please make sure the server is serving valid JSON for this request.",new Error(r);case 16:if(a=n.modelTopology,i=n.weightsManifest,o=n.generatedBy,s=n.convertedBy,u=n.format,l=n.signature,c=n.userDefinedMetadata,null!=a||null!=i){e.next=25;break}throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");case 25:if(null==i){e.next=31;break}return e.next=28,this.loadWeights(i);case 28:f=e.sent,p=f[0],h=f[1];case 31:return d={modelTopology:a,weightSpecs:p,weightData:h,generatedBy:o,convertedBy:s,format:u},null!=l&&(d.signature=l),null!=c&&(d.userDefinedMetadata=c),(m=n.modelInitializer)&&(d.modelInitializer=m),e.abrupt("return",d);case 37:case"end":return e.stop()}}),e,this,[[5,11]])})));return function(){return e.apply(this,arguments)}}(),t.loadWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r,a,i,o,s,u,l,c,p,h,f,d,m,v,g,y,b;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=Array.isArray(this.path)?this.path[1]:this.path,r=vb(n),a=r[0],i=r[1],o=this.weightPathPrefix||a,s=[],u=tv(t);!(l=u()).done;)c=l.value,s.push.apply(s,c.weights);for(p=[],h=[],f=tv(t);!(d=f()).done;)for(m=d.value,v=tv(m.paths);!(g=v()).done;)y=g.value,null!=this.weightUrlConverter?h.push(this.weightUrlConverter(y)):p.push(o+y+i);if(!this.weightUrlConverter){e.next=15;break}return e.t0=p.push,e.t1=p,e.next=13,Promise.all(h);case 13:e.t2=e.sent,e.t0.apply.call(e.t0,e.t1,e.t2);case 15:return e.next=17,cb(p,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress});case 17:return b=e.sent,e.abrupt("return",[s,by(b)]);case 19:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}();function vb(e){var t=e.lastIndexOf("/"),n=e.lastIndexOf("?");return[e.substring(0,t)+"/",n>t?e.substring(n):""]}function gb(e){return null!=e.match(mb.URL_SCHEME_REGEX)}mb.URL_SCHEME_REGEX=/^https?:\/\//;var yb=function(e,t){if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc))return null;return(Array.isArray(e)?e.every((function(e){return gb(e)})):gb(e))?bb(e,t):null};function bb(e,t){return new mb(e,t)}function xb(e,t){return bb(e,t)}Ny.registerSaveRouter(yb),Ny.registerLoadRouter(yb);var wb=function(){function e(e){this.modelArtifacts=e}return e.prototype.load=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.modelArtifacts);case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}(),kb=function(){function e(e){this.saveHandler=e}return e.prototype.save=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.saveHandler(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}();var Nb={__proto__:null,browserFiles:function(e){return new ub(e)},browserHTTPRequest:xb,concatenateArrayBuffers:by,decodeWeights:fy,encodeWeights:py,fromMemory:function(e,t,n,r){if(1===arguments.length){var a=null!=e.modelTopology||null!=e.weightSpecs;return a?new wb(e):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new wb({modelTopology:e}))}return console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new wb({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r})},getLoadHandlers:Sy,getModelArtifactsInfoForJSON:wy,getSaveHandlers:Iy,http:bb,isHTTPScheme:gb,loadWeights:hb,registerLoadRouter:function(e){return Ny.registerLoadRouter(e)},registerSaveRouter:function(e){return Ny.registerSaveRouter(e)},weightsLoaderFactory:db,withSaveHandler:function(e){return new kb(e)},copyModel:function(e,t){return Jy.apply(this,arguments)},listModels:function(){return Xy.apply(this,arguments)},moveModel:function(e,t){return Zy.apply(this,arguments)},removeModel:function(e){return Yy.apply(this,arguments)}};var Ib=oy({matMul_:function(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var a=ay(e,"a","matMul"),i=ay(t,"b","matMul"),o=Ug(a,i),s={a:a=o[0],b:i=o[1]},u={transposeA:n,transposeB:r};return Jg.runKernel("BatchMatMul",s,u)}});var Sb=oy({oneHot_:function(e,t,n,r){if(void 0===n&&(n=1),void 0===r&&(r=0),t<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+t);var a={indices:ay(e,"indices","oneHot","int32")},i={depth:t,onValue:n,offValue:r};return Jg.runKernel("OneHot",a,i)}});var Tb=oy({transpose_:function(e,t){var n=ay(e,"x","transpose");if(null==t&&(t=n.shape.map((function(e,t){return t})).reverse()),lv(n.rank===t.length,(function(){return"Error in transpose: rank of input "+n.rank+" must match length of perm "+t+"."})),t.forEach((function(e){lv(e>=0&&e<n.rank,(function(){return"All entries in 'perm' must be between 0 and "+(n.rank-1)+" but got "+t}))})),n.rank<=1)return n.clone();var r={x:n},a={perm:t};return Jg.runKernel("Transpose",r,a)}});var Cb,Eb={__proto__:null,confusionMatrix:oy({confusionMatrix_:function(e,t,n){var r=ay(e,"labels","confusionMatrix"),a=ay(t,"predictions","confusionMatrix");lv(null==n||n>0&&Number.isInteger(n),(function(){return"If provided, numClasses must be a positive integer, but got "+n})),lv(1===r.rank,(function(){return"Expected the rank of labels to be 1, but got "+r.rank})),lv(1===a.rank,(function(){return"Expected the rank of predictions to be 1, but got "+a.rank})),lv(r.shape[0]===a.shape[0],(function(){return"Mismatch in the number of examples: "+r.shape[0]+" vs. "+a.shape[0]+". Labels and predictions should have the same number of elements."})),lv(n>0&&Number.isInteger(n),(function(){return"numClasses is required to be a positive integer, but got "+n}));var i=Sb(rb(r,"int32"),n),o=Sb(rb(a,"int32"),n),s=Tb(i),u=Ib(s,o);return rb(u,"int32")}})};function Rb(e,t,n){if(pv(e),null!=t&&3!==t.length)throw new Error("tensor3d() requires shape to have three numbers");var r=ny(e,n);if(3!==r.length&&1!==r.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return uy(e,t,r,n)}function Ab(){return(Ab=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i,o,s,u,l,c,p,h,f,d,m,v,g,y;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ay(t,"img","toPixels"),t instanceof Fg||(r=rb(a=r,"int32"),a.dispose()),2===r.rank||3===r.rank){e.next=4;break}throw new Error("toPixels only supports rank 2 or 3 tensors, got rank "+r.rank+".");case 4:if(i=r.shape.slice(0,2),o=i[0],s=i[1],!((u=2===r.rank?1:r.shape[2])>4||2===u)){e.next=8;break}throw new Error("toPixels only supports depth of size 1, 3 or 4 but got "+u);case 8:if("float32"===r.dtype||"int32"===r.dtype){e.next=10;break}throw new Error("Unsupported type for toPixels: "+r.dtype+". Please use float32 or int32 tensors.");case 10:return e.next=12,r.data();case 12:l=e.sent,c="float32"===r.dtype?255:1,p=new Uint8ClampedArray(s*o*4),h=0;case 16:if(!(h<o*s)){e.next=41;break}f=[0,0,0,255],d=0;case 19:if(!(d<u)){e.next=33;break}if(m=l[h*u+d],"float32"!==r.dtype){e.next=26;break}if(!(m<0||m>1)){e.next=24;break}throw new Error("Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered "+m+".");case 24:e.next=29;break;case 26:if("int32"!==r.dtype){e.next=29;break}if(!(m<0||m>255)){e.next=29;break}throw new Error("Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered "+m+".");case 29:1===u?(f[0]=m*c,f[1]=m*c,f[2]=m*c):f[d]=m*c;case 30:d++,e.next=19;break;case 33:p[(v=4*h)+0]=Math.round(f[0]),p[v+1]=Math.round(f[1]),p[v+2]=Math.round(f[2]),p[v+3]=Math.round(f[3]);case 38:++h,e.next=16;break;case 41:return null!=n&&(n.width=s,n.height=o,g=n.getContext("2d"),y=new ImageData(p,s,o),g.putImageData(y,0,0)),r!==t&&r.dispose(),e.abrupt("return",p);case 44:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Db=oy({fromPixels_:function(e,t){if(void 0===t&&(t=3),t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==e)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");var n=!1,r=!1,a=!1,i=!1,o=!1;if(e.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&e instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)a=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)i=!0;else{if(null==e.getContext)throw new Error("pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was "+e.constructor.name);o=!0}if(a){if(a&&e.readyState<2)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.")}if(null!=cg("FromPixels",Jg.backendName)){var s={pixels:e},u={numChannels:t};return Jg.runKernel("FromPixels",s,u)}var l,c,p=a?[e.videoWidth,e.videoHeight]:[e.width,e.height],h=p[0],f=p[1];if(o?l=e.getContext("2d").getImageData(0,0,h,f).data:r||n?l=e.data:(i||a)&&(null==Cb&&(Cb=document.createElement("canvas").getContext("2d")),Cb.canvas.width=h,Cb.canvas.height=f,Cb.drawImage(e,0,0,h,f),l=Cb.getImageData(0,0,h,f).data),4===t)c=new Int32Array(l);else{var d=h*f;c=new Int32Array(d*t);for(var m=0;m<d;m++)for(var v=0;v<t;++v)c[m*t+v]=l[4*m+v]}return Rb(c,[f,h,t],"int32")}}),Fb={__proto__:null,toPixels:function(e,t){return Ab.apply(this,arguments)},fromPixels:Db};function _b(e,t){var n=e.shape.length,r=t.shape.length;if(n<1)throw new Error("tf.gatherND() expects the input to be rank 1 or higher, but the rank was "+n+".");if(r<1)throw new Error("tf.gatherND() expects the indices to be rank 1 or higher, but the rank was "+r+".");if("int32"!==t.dtype)throw new Error("tf.gatherND() expects the indices to be int32 type, but the dtype was "+t.dtype+".");if(t.shape[r-1]>n)throw new Error("index innermost dimension length must be <= tensor rank; saw: "+t.shape[r-1]+" vs. "+n);if(0===fv(e.shape))throw new Error("Requested more than 0 entries, but input is empty. Input shape: "+e.shape+".");for(var a=t.shape,i=a[a.length-1],o=1,s=0;s<a.length-1;++s)o*=a[s];var u=e.shape,l=a.slice();l.pop();for(var c=1,p=i;p<n;++p)c*=u[p],l.push(u[p]);var h=[].concat(Lv(e.shape).map((function(e){return e/c})),[1]).slice(0,i);return[l,o,c,h]}var Ob={__proto__:null,prepareAndValidate:_b};function Mb(e,t,n){var r=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,i="Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: "+n.shape+", indices.shape: "+t.shape+", shape: "+e+", sliceDim: "+r+", and batchDim: "+a+".";if(n.rank<a)throw new Error(i+" update.rank < "+a+". ");if(e.length<r+(n.rank-a))throw new Error(i+" Output shape length < "+(r+(n.rank-a)));if(n.rank!==a+e.length-r)throw new Error(i+" update.rank != "+(a+e.length-r));for(var o=0;o<a;++o)if(n.shape[o]!==t.shape[o])throw new Error(i+" updates.shape["+o+"] ("+n.shape[o]+") != indices.shape["+o+"] ("+t.shape[o]+").");for(var s=0;s<n.rank-a;++s)if(n.shape[s+a]!==e[s+r])throw new Error(i+" updates.shape["+(s+a)+"] ("+n.shape[s+a]+") != shape["+(s+a)+"] ("+e[s+a]+")")}function Lb(e,t,n){if(t.rank<1)throw new Error("tf.scatterND() expects the indices to be rank 1 or higher, but the rank was "+t.rank+".");if(e.rank<1)throw new Error("tf.scatterND() expects the updates to be rank 1 or higher, but the rank was "+e.rank+".");if("int32"!==t.dtype)throw new Error("The dtype of 'indices' should be int32, but got dtype: "+t.dtype);if(n.length<1)throw new Error("Output rank must be greater or equal to 1, but got shape: "+n);if(0===n.length){if(0===t.size)throw new Error("Indices specified for empty output. indices shape: "+t.shape);if(0===e.size)throw new Error("Updates specified for empty output. updates shape: "+e.shape)}Mb(n,t,e)}function zb(e,t,n){for(var r=t.shape.length,a=r>1?t.shape[r-1]:1,i=n.length,o=1,s=a;s<i;++s)o*=n[s];var u=a<1?1:a;return{sliceRank:a,numUpdates:fv(t.shape)/u,sliceSize:o,strides:[].concat(Lv(n.slice(0,a)),[1]),outputSize:fv(n)}}var Pb={__proto__:null,validateUpdateShape:Mb,validateInput:Lb,calculateShapes:zb};function Bb(e,t,n){var r=e.shape.length;lv(r===t.length,(function(){return"Error in slice"+r+"D: Length of begin "+t+" must match the rank of the array ("+r+")."})),lv(r===n.length,(function(){return"Error in slice"+r+"D: Length of size "+n+" must match the rank of the array ("+r+")."}));for(var a=function(a){lv(t[a]+n[a]<=e.shape[a],(function(){return"Error in slice"+r+"D: begin["+a+"] + size["+a+"] ("+(t[a]+n[a])+") would overflow input.shape["+a+"] ("+e.shape[a]+")"}))},i=0;i<r;++i)a(i)}function Wb(e){for(var t=[],n=0;e>0;)1&e&&t.push(n),e/=2,n++;return t}function Vb(e,t,n){for(var r=[],a=0;a<e.length;a++)r[a]=Math.ceil((t[a]-e[a])/n[a]);return r}function Ub(e,t,n,r){for(var a=[].concat(e),i=a.length;i<r.length;i++)a.push(1);for(var o=0;o<n;o++)0===o?a[t]=1:(a.splice(t,0,1),a.pop());return a}function Gb(e,t,n){return n<=e?n:n-(t-1)}function jb(e,t){for(var n=[],r=0;r<e;r++)n.push(t+r);return n}function Hb(e,t,n,r,a,i,o,s,u){var l=e.length,c=new Array(l),p=new Array(l),h=new Array(l);if(t.length&&n>0){var f=t[0],d=n+1;c=qb(o,f,d,r,e),p=Kb(s,f,d,a,e),h=Ub(i,f,d,e)}else for(var m=0;m<l;m++)c[m]=Yb(o,r,i,e,m,u),p[m]=Jb(s,a,i,e,m,u),h[m]=Xb(i,m,u);return{begin:c,end:p,strides:h}}function qb(e,t,n,r,a){for(var i=[].concat(a),o=jb(n,t),s=0;s<i.length;s++)if(o.indexOf(s)>-1)i[s]=0;else{var u=Gb(t,n,s),l=r[u];e&1<<u&&(l=0),i[s]=l}return i}function Kb(e,t,n,r,a){for(var i=[].concat(a),o=jb(n,t),s=0;s<i.length;s++)if(o.indexOf(s)>-1)i[s]=Number.MAX_SAFE_INTEGER;else{var u=Gb(t,n,s),l=r[u];e&1<<u&&(l=Number.MAX_SAFE_INTEGER),i[s]=l}for(var c=0;c<i.length;c++){var p=a[c];i[c]<0&&(i[c]+=p),i[c]=ov(0,i[c],a[c])}return i}function Xb(e,t,n){var r=e[t];return(n&1<<t||null==r)&&(r=1),r}function Yb(e,t,n,r,a,i){var o=t[a],s=n[a]||1;(e&1<<a||i&1<<a||null==o)&&(o=s>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);var u=r[a];return o<0&&(o+=u),o=ov(0,o,u-1)}function Jb(e,t,n,r,a,i){var o=t[a],s=n[a]||1;(e&1<<a||i&1<<a||null==o)&&(o=s>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);var u=r[a];return o<0&&(o+=u),o=s>0?ov(0,o,u):ov(-1,o,u-1)}function Zb(e,t,n){for(var r=n.length,a=0;a<n.length;a++)if(n[a]>1){r=a;break}for(var i=r+1;i<n.length;i++)if(t[i]>0||n[i]!==e[i])return!1;return!0}function Qb(e,t){for(var n=e.length>0?e[e.length-1]:1,r=0;r<e.length-1;r++)n+=e[r]*t[r];return n}function $b(e,t,n){var r,a,i=e.shape.length;return(r="number"==typeof t?[t].concat(new Array(i-1).fill(0)):t.length<i?t.concat(new Array(i-t.length).fill(0)):t.slice()).forEach((function(e){lv(-1!==e,(function(){return"slice() does not support negative begin indexing."}))})),a=(a=null==n?new Array(i).fill(-1):"number"==typeof n?[n].concat(new Array(i-1).fill(-1)):n.length<i?n.concat(new Array(i-n.length).fill(-1)):n).map((function(t,n){return t>=0?t:(lv(-1===t,(function(){return"Negative size values should be exactly -1 but got "+t+" for the slice() size at index "+n+"."})),e.shape[n]-r[n])})),[r,a]}function ex(e,t,n,r,a,i,o,s,u){var l=t.slice(),c=n.slice(),p=r;null==r&&(p=new Array(l.length));var h=Wb(o);if(h.length>1)throw new Error("Multiple ellipses in slice is not allowed.");if(0!==o&&0!==s)throw new Error("Using both ellipsisMask and newAxisMask is not yet supported.");if(0!==o&&0!==u)throw new Error("Using both ellipsisMask and shrinkAxisMask is not yet supported.");var f=e.length-l.length,d=Wb(s),m=e.slice();d.forEach((function(e){l[e]=0,c[e]=1,m.splice(e,0,1)}));var v=Hb(m,h,f,l,c,p,a,i,o),g=v.begin,y=v.end,b=v.strides;l=g,c=y,p=b;var x=Wb(u);x.forEach((function(e){c[e]=l[e]+1,p[e]=1}));var w=Vb(l,c,p),k=w.filter((function(e,t){return-1===x.indexOf(t)}));return{nonStrided:p.every((function(e){return 1===e})),$begin:l,$end:c,$strides:p,size:w,newShape:m,outShape:k}}var tx={__proto__:null,assertParamsValid:Bb,maskToAxes:Wb,computeOutShape:Vb,stridesWithElidedDims:Ub,getNormalizedAxes:Hb,startIndicesWithElidedDims:qb,stopIndicesWithElidedDims:Kb,stridesForAxis:Xb,startForAxis:Yb,stopForAxis:Jb,isSliceContinous:Zb,computeFlatOffset:Qb,parseSliceParams:$b,sliceInfo:ex},nx=function(){function e(){}return e.prototype.getClassName=function(){return this.constructor.className},e.fromConfig=function(e,t){return new e(t)},e}(),rx=function(){function e(){this.classNameMap={}}return e.getMap=function(){return null==e.instance&&(e.instance=new e),e.instance},e.register=function(t){e.getMap().classNameMap[t.className]=[t,t.fromConfig]},e}();function ax(e){lv(null!=e.className,(function(){return"Class being registered does not have the static className property defined."})),lv("string"==typeof e.className,(function(){return"className is required to be a string, but got type "+typeof e.className})),lv(e.className.length>0,(function(){return"Class being registered has an empty-string as its className, which is disallowed."})),rx.register(e)}var ix={__proto__:null,Serializable:nx,SerializationMap:rx,registerClass:ax};function ox(){return 32===Jg.backend.floatPrecision()?.001:.1}function sx(e,t,n){var r=!0;if((Cv(e)||Cv(t))&&(r=!1),Cv(e)&&Cv(t)&&(r=!0),r){var a=e.constructor.name,i=t.constructor.name;if(a!==i)throw new Error("Arrays are of different type. Actual: "+a+". Expected: "+i)}if(Array.isArray(e)&&Array.isArray(t)){var o=ny(e),s=ny(t);if(!dv(o,s))throw new Error("Arrays have different shapes. Actual: ["+o+"]. Expected: ["+s+"]")}var u=Cv(e)?e:hv(e),l=Cv(t)?t:hv(t);if(u.length!==l.length)throw new Error("Arrays have different lengths actual: "+u.length+" vs expected: "+l.length+".\nActual:   "+u+".\nExpected: "+l+".");for(var c=0;c<l.length;++c){var p=u[c],h=l[c];if(!n(p,h))throw new Error("Arrays differ: actual["+c+"] = "+p+", expected["+c+"] = "+h+".\nActual:   "+u+".\nExpected: "+l+".")}}function ux(e,t,n){if(null==n&&(n=ox()),!lx(e,t,n))throw new Error("Numbers differ: actual === "+e+", expected === "+t)}function lx(e,t,n){return!isFinite(e)&&!isFinite(t)||!(isNaN(e)||isNaN(t)||Math.abs(e-t)>n)}var cx={__proto__:null,TEST_EPSILON_FLOAT16:.1,expectArraysClose:function(e,t,n){return null==n&&(n=ox()),sx(e,t,(function(e,t){return lx(e,t,n)}))},testEpsilon:ox,expectPromiseToFail:function(e,t){e().then((function(){return t.fail()}),(function(){return t()}))},expectArraysEqual:function(e,t){var n="string"==typeof t||"number"==typeof t||"boolean"==typeof t?[t]:t;return Av(e)||Av(e[0])||Av(t)||Av(t[0])?sx(e,n,(function(e,t){return e==t})):sx(e,t,(function(e,t){return lx(e,t,0)}))},expectNumbersClose:ux,expectValuesInRange:function(e,t,n){for(var r=0;r<e.length;r++)if(e[r]<t||e[r]>n)throw new Error("Value out of range:"+e[r]+" low: "+t+", high: "+n)},expectArrayBuffersEqual:function(e,t){expect(new Float32Array(e)).toEqual(new Float32Array(t))},encodeStrings:function e(t){for(var n=0;n<t.length;n++){var r=t[n];Array.isArray(r)?e(r):t[n]=xg(r)}return t}};function px(e){Xv().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(e+" You can disable deprecation warnings with tf.disableDeprecationWarnings().")}function hx(){return Jg}function fx(){return Jg.memory()}function dx(e,t){return Jg.tidy(e,t)}function mx(e){Hg(e).forEach((function(e){return e.dispose()}))}function vx(e){return Jg.keep(e)}function gx(e){return Jg.setBackend(e)}function yx(e,t,n){return void 0===n&&(n=1),Jg.registerBackend(e,t,n)}function bx(){return Jg.backend}var xx=oy({add_:function(e,t){var n=ay(e,"a","add"),r=ay(t,"b","add"),a=Ug(n,r),i={a:n=a[0],b:r=a[1]};return Jg.runKernel(Zv,i)}});var wx=oy({floorDiv_:function(e,t){var n=ay(e,"a","floorDiv"),r=ay(t,"b","floorDiv"),a=Ug(n,r),i={a:n=a[0],b:r=a[1]};return Jg.runKernel("FloorDiv",i)}});var kx=oy({div_:function(e,t){var n=ay(e,"a","div"),r=ay(t,"b","div"),a=Ug(n,r);if(n=a[0],r=a[1],"int32"===n.dtype&&"int32"===r.dtype)return wx(n,r);var i={a:n,b:r};return Jg.runKernel("RealDiv",i,{})}});var Nx=oy({mul_:function(e,t){var n=ay(e,"a","mul"),r=ay(t,"b","mul"),a=Ug(n,r),i={a:n=a[0],b:r=a[1]};return Jg.runKernel("Multiply",i)}});var Ix=oy({abs_:function(e){var t=ay(e,"x","abs");if("complex64"===t.dtype){var n={x:t};return Jg.runKernel("ComplexAbs",n)}var r={x:t};return Jg.runKernel("Abs",r)}});var Sx=oy({acos_:function(e){var t={x:ay(e,"x","acos")};return Jg.runKernel("Acos",t)}});var Tx=oy({acosh_:function(e){var t={x:ay(e,"x","acosh")};return Jg.runKernel("Acosh",t)}});var Cx=oy({addN_:function(e){lv(Array.isArray(e),(function(){return"The argument passed to tf.addN() must be a list of tensors"})),lv(e.length>=1,(function(){return"Must pass at least one tensor to tf.addN(), but got "+e.length}));var t=e.map((function(e,t){return ay(e,"tensors"+t,"addN")})),n=t[0];t.forEach((function(e){if(e.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),t.forEach((function(e){if(!dv(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));var r=t;return Jg.runKernel("AddN",r)}});var Ex=oy({all_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r={x:ay(e,"x","all","bool")},a={axis:t,keepDims:n};return Jg.runKernel("All",r,a)}});var Rx=oy({any_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r={x:ay(e,"x","any","bool")},a={axis:t,keepDims:n};return Jg.runKernel("Any",r,a)}});var Ax=oy({argMax_:function(e,t){void 0===t&&(t=0);var n={x:ay(e,"x","argMax")},r={axis:t};return Jg.runKernel("ArgMax",n,r)}});var Dx=oy({argMin_:function(e,t){void 0===t&&(t=0);var n={x:ay(e,"x","argMin")},r={axis:t};return Jg.runKernel("ArgMin",n,r)}});var Fx=oy({asin_:function(e){var t={x:ay(e,"x","asin")};return Jg.runKernel("Asin",t)}});var _x=oy({asinh_:function(e){var t={x:ay(e,"x","asinh")};return Jg.runKernel("Asinh",t)}});var Ox=oy({atan_:function(e){var t={x:ay(e,"x","atan")};return Jg.runKernel("Atan",t)}});var Mx=oy({atan2_:function(e,t){var n=ay(e,"a","atan2"),r=ay(t,"b","atan2"),a=Ug(n,r),i={a:n=a[0],b:r=a[1]};return Jg.runKernel("Atan2",i)}});var Lx=oy({atanh_:function(e){var t={x:ay(e,"x","atanh")};return Jg.runKernel("Atanh",t)}});function zx(e,t,n,r,a,i){void 0===a&&(a="NHWC");var o=e[3];return Wx(e,[].concat(t,[o]),n,i,r,null,null,Yx(a))}function Px(e,t,n,r,a,i,o){void 0===o&&(o="channelsLast");var s,u=Gx(t),l=u[0],c=u[1];if("channelsLast"===o)s=[l,c,e[3],e[3]];else{if("channelsFirst"!==o)throw new Error("Unknown dataFormat "+o);s=[l,c,e[1],e[1]]}return Wx(e,s,n,r,a,i,!1,o)}function Bx(e,t,n,r,a,i,o){void 0===o&&(o="NDHWC");var s,u,l=jx(t),c=l[0],p=l[1],h=l[2];if("NDHWC"===o)u="channelsLast",s=[c,p,h,e[4],e[4]];else{if("NCDHW"!==o)throw new Error("Unknown dataFormat "+o);u="channelsFirst",s=[c,p,h,e[1],e[1]]}return Vx(e,s,n,r,a,!1,u,i)}function Wx(e,t,n,r,a,i,o,s){void 0===o&&(o=!1),void 0===s&&(s="channelsLast");var u=-1,l=-1,c=-1,p=-1;if("channelsLast"===s)u=e[0],l=e[1],c=e[2],p=e[3];else{if("channelsFirst"!==s)throw new Error("Unknown dataFormat "+s);u=e[0],p=e[1],l=e[2],c=e[3]}var h,f=t[0],d=t[1],m=t[3],v=Gx(n),g=v[0],y=v[1],b=Gx(r),x=b[0],w=b[1],k=Hx(f,x),N=Hx(d,w),I=function(e,t,n,r,a,i,o,s,u){var l,c,p;if("number"==typeof e){l={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};var h=function(e,t,n,r,a){null==r&&(r=Ux(e,t,n));var i=e[0],o=e[1],s=qx((i-t+2*r)/n+1,a),u=qx((o-t+2*r)/n+1,a);return[s,u]}([t,n],i,r,e,s);c=h[0],p=h[1]}else if("same"===e){c=Math.ceil(t/r),p=Math.ceil(n/a);var f=Math.max(0,(c-1)*r+i-t),d=Math.max(0,(p-1)*a+o-n),m=Math.floor(f/2),v=f-m,g=Math.floor(d/2);l={top:m,bottom:v,left:g,right:d-g,type:"SAME"}}else if("valid"===e)l={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-i+1)/r),p=Math.ceil((n-o+1)/a);else{if("object"!=typeof e)throw Error("Unknown padding parameter: "+e);var y="channelsLast"===u?e[1][0]:e[2][0],b="channelsLast"===u?e[1][1]:e[2][1],x="channelsLast"===u?e[2][0]:e[3][0],w="channelsLast"===u?e[2][1]:e[3][1];l={top:y,bottom:b,left:x,right:w,type:0===y&&0===b&&0===x&&0===w?"VALID":"EXPLICIT"},c=qx((t-i+y+b)/r+1,s),p=qx((n-o+x+w)/a+1,s)}return{padInfo:l,outHeight:c,outWidth:p}}(a,l,c,g,y,k,N,i,s),S=I.padInfo,T=I.outHeight,C=I.outWidth,E=o?m*p:m;return"channelsFirst"===s?h=[u,E,T,C]:"channelsLast"===s&&(h=[u,T,C,E]),{batchSize:u,dataFormat:s,inHeight:l,inWidth:c,inChannels:p,outHeight:T,outWidth:C,outChannels:E,padInfo:S,strideHeight:g,strideWidth:y,filterHeight:f,filterWidth:d,effectiveFilterHeight:k,effectiveFilterWidth:N,dilationHeight:x,dilationWidth:w,inShape:e,outShape:h,filterShape:t}}function Vx(e,t,n,r,a,i,o,s){void 0===i&&(i=!1),void 0===o&&(o="channelsLast");var u=-1,l=-1,c=-1,p=-1,h=-1;if("channelsLast"===o)u=e[0],l=e[1],c=e[2],p=e[3],h=e[4];else{if("channelsFirst"!==o)throw new Error("Unknown dataFormat "+o);u=e[0],h=e[1],l=e[2],c=e[3],p=e[4]}var f,d=t[0],m=t[1],v=t[2],g=t[4],y=jx(n),b=y[0],x=y[1],w=y[2],k=jx(r),N=k[0],I=k[1],S=k[2],T=Hx(d,N),C=Hx(m,I),E=Hx(v,S),R=function(e,t,n,r,a,i,o,s,u,l,c){var p,h,f,d;if("number"==typeof e){p={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};var m=function(e,t,n,r,a,i){null==a&&(a=Ux(e,t,r));var o=e[0],s=e[1],u=e[2],l=qx((o-t+2*a)/r+1,i),c=qx((s-t+2*a)/r+1,i),p=qx((u-t+2*a)/r+1,i);return[l,c,p,n]}([t,n,r,1],s,1,a,e,c);h=m[0],f=m[1],d=m[2]}else if("same"===e){h=Math.ceil(t/a),f=Math.ceil(n/i),d=Math.ceil(r/o);var v=(h-1)*a+s-t,g=(f-1)*i+u-n,y=(d-1)*o+l-r,b=Math.floor(v/2),x=v-b,w=Math.floor(g/2),k=g-w,N=Math.floor(y/2);p={top:w,bottom:k,left:N,right:y-N,front:b,back:x,type:"SAME"}}else{if("valid"!==e)throw Error("Unknown padding parameter: "+e);p={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},h=Math.ceil((t-s+1)/a),f=Math.ceil((n-u+1)/i),d=Math.ceil((r-l+1)/o)}return{padInfo:p,outDepth:h,outHeight:f,outWidth:d}}(a,l,c,p,b,x,w,T,C,E,s),A=R.padInfo,D=R.outDepth,F=R.outHeight,_=R.outWidth,O=i?g*h:g;return"channelsFirst"===o?f=[u,O,D,F,_]:"channelsLast"===o&&(f=[u,D,F,_,O]),{batchSize:u,dataFormat:o,inDepth:l,inHeight:c,inWidth:p,inChannels:h,outDepth:D,outHeight:F,outWidth:_,outChannels:O,padInfo:A,strideDepth:b,strideHeight:x,strideWidth:w,filterDepth:d,filterHeight:m,filterWidth:v,effectiveFilterDepth:T,effectiveFilterHeight:C,effectiveFilterWidth:E,dilationDepth:N,dilationHeight:I,dilationWidth:S,inShape:e,outShape:f,filterShape:t}}function Ux(e,t,n,r){void 0===r&&(r=1);var a=Hx(t,r);return Math.floor((e[0]*(n-1)-n+a)/2)}function Gx(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function jx(e){return"number"==typeof e?[e,e,e]:e}function Hx(e,t){return t<=1?e:e+(e-1)*(t-1)}function qx(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error("Unknown roundingMode "+t)}}function Kx(e){var t=Gx(e),n=t[0],r=t[1],a=t[2];return 1===n&&1===r&&1===a}function Xx(e,t){return Kx(e)||Kx(t)}function Yx(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error("Unknown dataFormat "+e)}var Jx=oy({reshape_:function(e,t){var n={x:ay(e,"x","reshape",null)},r={shape:t};return Jg.runKernel("Reshape",n,r)}});var Zx=oy({avgPool_:function(e,t,n,r,a){var i=ay(e,"x","avgPool","float32");lv(Xx(n,1),(function(){return"Error in avgPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '1'"}));var o=i,s=!1;3===i.rank&&(s=!0,o=Jx(i,[1,i.shape[0],i.shape[1],i.shape[2]])),lv(4===o.rank,(function(){return"Error in avgPool: x must be rank 4 but got rank "+o.rank+"."})),null!=a&&lv(mv(r),(function(){return"Error in avgPool: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+"."}));var u={x:o},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a},c=Jg.runKernel("AvgPool",u,l);return c=rb(c,i.dtype),s?Jx(c,[c.shape[1],c.shape[2],c.shape[3]]):c}});var Qx=oy({avgPool3d_:function(e,t,n,r,a,i,o){void 0===i&&(i="NDHWC"),null==o?o=[1,1,1]:px("dilations is deprecated, this field will be gone in v3.0.0.");var s=ay(e,"x","avgPool3d","float32"),u=s,l=!1;4===s.rank&&(l=!0,u=Jx(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),lv(5===u.rank,(function(){return"Error in avgPool3d: x must be rank 5 but got rank "+u.rank+"."})),lv("NDHWC"===i,(function(){return"Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of "+i})),lv(Xx(n,o),(function(){return"Error in avgPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+o+"'"})),null!=a&&lv(mv(r),(function(){return"Error in avgPool3d: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+"."}));var c={x:u},p={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i,dilations:o},h=Jg.runKernel("AvgPool3D",c,p);return h=rb(h,u.dtype),l?Jx(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}});var $x=oy({concat_:function(e,t){void 0===t&&(t=0),lv(e.length>=1,(function(){return"Pass at least one tensor to concat"}));var n=iy(e,"tensors","concat");if("complex64"===n[0].dtype&&n.forEach((function(e){if("complex64"!==e.dtype)throw new Error("Cannot concatenate complex64 tensors with a tensor\n          with dtype "+e.dtype+". ")})),1===n.length)return ab(n[0]);var r=n,a={axis:t};return Jg.runKernel("Concat",r,a)}});var ew=oy({sigmoid_:function(e){var t={x:ay(e,"x","sigmoid")};return Jg.runKernel("Sigmoid",t)}});var tw=oy({slice_:function(e,t,n){var r=ay(e,"x","slice",null);if(0===r.rank)throw new Error("Slicing scalar is not possible");var a={x:r},i={begin:t,size:n};return Jg.runKernel("Slice",a,i)}});var nw=oy({tanh_:function(e){var t={x:ay(e,"x","tanh")};return Jg.runKernel("Tanh",t)}});var rw=oy({basicLSTMCell_:function(e,t,n,r,a,i){var o=ay(e,"forgetBias","basicLSTMCell"),s=ay(t,"lstmKernel","basicLSTMCell"),u=ay(n,"lstmBias","basicLSTMCell"),l=ay(r,"data","basicLSTMCell"),c=ay(a,"c","basicLSTMCell"),p=ay(i,"h","basicLSTMCell"),h=$x([l,p],1),f=Ib(h,s),d=xx(f,u),m=d.shape[0],v=d.shape[1]/4,g=[m,v],y=tw(d,[0,0],g),b=tw(d,[0,v],g),x=tw(d,[0,2*v],g),w=tw(d,[0,3*v],g),k=xx(Nx(ew(y),nw(b)),Nx(c,ew(xx(o,x))));return[k,Nx(nw(k),ew(w))]}});var aw=oy({batchToSpaceND_:function(e,t,n){var r=ay(e,"x","batchToSpaceND"),a=t.reduce((function(e,t){return e*t}));lv(r.rank>=1+t.length,(function(){return"input rank is "+r.rank+" but should be > than blockShape.length "+t.length})),lv(n.length===t.length,(function(){return"crops.length is "+n.length+" but should be equal to blockShape.length  "+t.length})),lv(r.shape[0]%a==0,(function(){return"input tensor batch is "+r.shape[0]+" but is not divisible by the product of the elements of blockShape "+t.join(" * ")+" === "+a}));var i={x:r},o={blockShape:t,crops:n};return Jg.runKernel("BatchToSpaceND",i,o)}});var iw=oy({batchNorm_:function(e,t,n,r,a,i){null==i&&(i=.001);var o,s,u=ay(e,"x","batchNorm"),l=ay(t,"mean","batchNorm"),c=ay(n,"variance","batchNorm");null!=a&&(o=ay(a,"scale","batchNorm")),null!=r&&(s=ay(r,"offset","batchNorm")),lv(l.rank===c.rank,(function(){return"Batch normalization gradient requires mean and variance to have equal ranks."})),lv(null==s||l.rank===s.rank,(function(){return"Batch normalization gradient requires mean and offset to have equal ranks."})),lv(null==o||l.rank===o.rank,(function(){return"Batch normalization gradient requires mean and scale to have equal ranks."}));var p={x:function(e){return 0===e.rank||1===e.rank?Jx(e,[1,1,1,e.size]):2===e.rank?Jx(e,[1,1,e.shape[0],e.shape[1]]):3===e.rank?Jx(e,[1,e.shape[0],e.shape[1],e.shape[2]]):e}(u),scale:o,offset:s,mean:l,variance:c},h={varianceEpsilon:i},f=Jg.runKernel("FusedBatchNorm",p,h);return Jx(f,u.shape)}});var ow=oy({batchNorm2d_:function(e,t,n,r,a,i){var o,s,u=ay(e,"x","batchNorm"),l=ay(t,"mean","batchNorm"),c=ay(n,"variance","batchNorm");return null!=a&&(o=ay(a,"scale","batchNorm")),null!=r&&(s=ay(r,"offset","batchNorm")),lv(2===u.rank,(function(){return"Error in batchNorm2D: x must be rank 2 but got rank "+u.rank+"."})),lv(2===l.rank||1===l.rank,(function(){return"Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank "+l.rank+"."})),lv(2===c.rank||1===c.rank,(function(){return"Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank "+c.rank+"."})),null!=o&&lv(2===o.rank||1===o.rank,(function(){return"Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank "+o.rank+"."})),null!=s&&lv(2===s.rank||1===s.rank,(function(){return"Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank "+s.rank+"."})),iw(u,l,c,s,o,i)}});var sw=oy({batchNorm3d_:function(e,t,n,r,a,i){var o,s,u=ay(e,"x","batchNorm"),l=ay(t,"mean","batchNorm"),c=ay(n,"variance","batchNorm");return null!=a&&(o=ay(a,"scale","batchNorm")),null!=r&&(s=ay(r,"offset","batchNorm")),lv(3===u.rank,(function(){return"Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+"."})),lv(3===l.rank||1===l.rank,(function(){return"Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank "+l.rank+"."})),lv(3===c.rank||1===c.rank,(function(){return"Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank "+c.rank+"."})),null!=o&&lv(3===o.rank||1===o.rank,(function(){return"Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank "+o.rank+"."})),null!=s&&lv(3===s.rank||1===s.rank,(function(){return"Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank "+s.rank+"."})),iw(u,l,c,s,o,i)}});var uw=oy({batchNorm4d_:function(e,t,n,r,a,i){var o,s,u=ay(e,"x","batchNorm"),l=ay(t,"mean","batchNorm"),c=ay(n,"variance","batchNorm");return null!=a&&(o=ay(a,"scale","batchNorm")),null!=r&&(s=ay(r,"offset","batchNorm")),lv(4===u.rank,(function(){return"Error in batchNorm4D: x must be rank 4 but got rank "+u.rank+"."})),lv(4===l.rank||1===l.rank,(function(){return"Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank "+l.rank+"."})),lv(4===c.rank||1===c.rank,(function(){return"Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank "+c.rank+"."})),null!=o&&lv(4===o.rank||1===o.rank,(function(){return"Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank "+o.rank+"."})),null!=s&&lv(4===s.rank||1===s.rank,(function(){return"Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank "+s.rank+"."})),iw(u,l,c,s,o,i)}});var lw=oy({bincount_:function(e,t,n){var r=ay(e,"x","bincount"),a=ay(t,"weights","bincount");lv("int32"===r.dtype,(function(){return"Error in bincount: input dtype must be int32, but got "+r.dtype})),lv(n>=0,(function(){return"size must be non-negative, but got "+n+"."})),lv(a.size===r.size||0===a.size,(function(){return"Error in bincount: weights must have the same size as input or0-length, but got input shape: "+r.shape+", weights shape: "+a.shape+"."}));var i={x:r,weights:a},o={size:n};return Jg.runKernel("Bincount",i,o)}});var cw=oy({broadcastTo_:function(e,t){var n=ay(e,"broadcastTo","x"),r=n.shape;if(t.some((function(e){return!(e>0)||e%1!=0})))throw new Error("broadcastTo(): Invalid broadcast shape ["+t+"].");if(t.length<n.rank)throw new Error("broadcastTo(): shape.length="+t.length+" < input.rank="+n.rank+".");if(t.length>n.rank){for(var a=n.shape.slice();a.length<t.length;)a.unshift(1);n=Jx(n,a)}for(var i=n.shape,o=Array.from(t),s=t.length-1;s>=0;s--)if(i[s]===t[s])o[s]=1;else if(1!==n.shape[s])throw new Error("broadcastTo(): ["+r+"] cannot be broadcast to ["+t+"].");if(0===o.map((function(e,t){return e>1?t:-1})).filter((function(e){return e>=0})).length)return ab(n);var u={x:n},l={reps:o};return Jg.runKernel("Tile",u,l)}});var pw=oy({ceil_:function(e){var t={x:ay(e,"x","ceil")};return Jg.runKernel("Ceil",t)}});var hw=oy({clipByValue_:function(e,t,n){var r=ay(e,"x","clipByValue");lv(t<=n,(function(){return"Error in clip: min ("+t+") must be less than or equal to max ("+n+")."}));var a={x:r},i={clipValueMin:t,clipValueMax:n};return Jg.runKernel("ClipByValue",a,i)}});var fw=oy({concat1d_:function(e){return $x(e,0)}});var dw=oy({concat2d_:function(e,t){return $x(e,t)}});var mw=oy({concat3d_:function(e,t){return $x(e,t)}});var vw=oy({concat4d_:function(e,t){return $x(e,t)}});var gw=oy({conv2d_:function(e,t,n,r,a,i,o){void 0===a&&(a="NHWC"),void 0===i&&(i=[1,1]);var s=ay(e,"x","conv2d"),u=ay(t,"filter","conv2d"),l=s,c=!1;3===s.rank&&(c=!0,l=Jx(s,[1,s.shape[0],s.shape[1],s.shape[2]])),lv(4===l.rank,(function(){return"Error in conv2d: input must be rank 4, but got rank "+l.rank+"."})),lv(4===u.rank,(function(){return"Error in conv2d: filter must be rank 4, but got rank "+u.rank+"."})),null!=o&&lv(mv(r),(function(){return"Error in conv2d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+r+"."}));var p="NHWC"===a?l.shape[3]:l.shape[1];lv(p===u.shape[2],(function(){return"Error in conv2d: depth of input ("+p+") must match input depth for filter "+u.shape[2]+"."})),lv(Xx(n,i),(function(){return"Error in conv2D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+i+"'"}));var h={x:l,filter:u},f={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:o},d=Jg.runKernel("Conv2D",h,f);return c?Jx(d,[d.shape[1],d.shape[2],d.shape[3]]):d}});var yw=oy({conv1d_:function(e,t,n,r,a,i,o){void 0===a&&(a="NWC"),void 0===i&&(i=1);var s=ay(e,"x","conv1d"),u=ay(t,"filter","conv1d"),l=s,c=!1;2===s.rank&&(c=!0,l=Jx(s,[1,s.shape[0],s.shape[1]])),lv(3===l.rank,(function(){return"Error in conv1d: input must be rank 3, but got rank "+l.rank+"."})),lv(3===u.rank,(function(){return"Error in conv1d: filter must be rank 3, but got rank "+u.rank+"."})),null!=o&&lv(mv(r),(function(){return"Error in conv1d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+r+"."})),lv(l.shape[2]===u.shape[1],(function(){return"Error in conv1d: depth of input ("+l.shape[2]+") must match input depth for filter "+u.shape[1]+"."})),lv(Xx(n,i),(function(){return"Error in conv1D: Either stride or dilation must be 1. Got stride "+n+" and dilation '"+i+"'"})),lv("NWC"===a,(function(){return"Error in conv1d: got dataFormat of "+a+" but only NWC is currently supported."}));var p=Jx(u,[1,u.shape[0],u.shape[1],u.shape[2]]),h=Jx(l,[l.shape[0],1,l.shape[1],l.shape[2]]),f=gw(h,p,[1,n],r,"NHWC",[1,i],o);return Jx(f,c?[f.shape[2],f.shape[3]]:[f.shape[0],f.shape[2],f.shape[3]])}});var bw=oy({conv2DBackpropInput_:function(e,t,n,r,a,i,o){void 0===i&&(i="NHWC"),lv(e.length===t.rank,(function(){return"Length of inShape ("+e.length+") and rank of dy ("+t.rank+") must match"}));var s=e,u=t,l=!1;3===t.rank&&(l=!0,u=Jx(t,[1,t.shape[0],t.shape[1],t.shape[2]]),s=[1,e[0],e[1],e[2]]),lv(4===s.length,(function(){return"Error in conv2dDerInput: inShape must be length 4, but got length "+s.length+"."})),lv(4===u.rank,(function(){return"Error in conv2dDerInput: dy must be rank 4, but got rank "+u.rank})),lv(4===n.rank,(function(){return"Error in conv2dDerInput: filter must be rank 4, but got rank "+n.rank}));var c="NHWC"===i?s[3]:s[1],p="NHWC"===i?u.shape[3]:u.shape[1];lv(c===n.shape[2],(function(){return"Error in conv2dDerInput: depth of input ("+c+") must match input depth for filter "+n.shape[2]+"."})),lv(p===n.shape[3],(function(){return"Error in conv2dDerInput: depth of output ("+p+") must match output depth for filter "+n.shape[3]+"."})),null!=o&&lv(mv(a),(function(){return"Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+a+"."}));var h={dy:u,filter:n},f={strides:r,pad:a,dataFormat:i,dimRoundingMode:o,inputShape:s},d=Jg.runKernel("Conv2DBackpropInput",h,f);return l?Jx(d,[d.shape[1],d.shape[2],d.shape[3]]):d}});var xw=oy({conv2dTranspose_:function(e,t,n,r,a,i){var o=ay(e,"x","conv2dTranspose"),s=ay(t,"filter","conv2dTranspose");return bw(n,o,s,r,a,"NHWC",i)}});var ww=oy({conv3d_:function(e,t,n,r,a,i){void 0===a&&(a="NDHWC"),void 0===i&&(i=[1,1,1]);var o=ay(e,"x","conv3d"),s=ay(t,"filter","conv3d"),u=o,l=!1;4===o.rank&&(l=!0,u=Jx(o,[1,o.shape[0],o.shape[1],o.shape[2],o.shape[3]])),lv(5===u.rank,(function(){return"Error in conv3d: input must be rank 5, but got rank "+u.rank+"."})),lv(5===s.rank,(function(){return"Error in conv3d: filter must be rank 5, but got rank "+s.rank+"."})),lv(u.shape[4]===s.shape[3],(function(){return"Error in conv3d: depth of input ("+u.shape[4]+") must match input depth for filter "+s.shape[3]+"."})),lv(Xx(n,i),(function(){return"Error in conv3D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+i+"'"})),lv("NDHWC"===a,(function(){return"Error in conv3d: got dataFormat of "+a+" but only NDHWC is currently supported."}));var c={x:u,filter:s},p={strides:n,pad:r,dataFormat:a,dilations:i},h=Jg.runKernel("Conv3D",c,p);return l?Jx(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}});var kw=oy({conv3DBackpropInput_:function(e,t,n,r,a){lv(e.length===t.rank,(function(){return"Length of inShape ("+e.length+") and rank of dy ("+t.rank+") must match"}));var i=e,o=t,s=!1;4===t.rank&&(s=!0,o=Jx(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),i=[1,e[0],e[1],e[2],e[3]]);var u=i[4],l=o.shape[4];lv(5===i.length,(function(){return"Error in conv3dDerInput: inShape must be length 5, but got length "+i.length+"."})),lv(5===o.rank,(function(){return"Error in conv3dDerInput: dy must be rank 5, but got rank "+o.rank})),lv(5===n.rank,(function(){return"Error in conv3dDerInput: filter must be rank 5, but got rank "+n.rank})),lv(u===n.shape[3],(function(){return"Error in conv3dDerInput: depth of input ("+u+") must match input depth for filter "+n.shape[3]+"."})),lv(l===n.shape[4],(function(){return"Error in conv3dDerInput: depth of output ("+l+") must match output depth for filter "+n.shape[4]+"."}));var c={dy:o,filter:n},p={pad:a,strides:r,inputShape:i},h=Jg.runKernel("Conv3DBackpropInputV2",c,p);return s?Jx(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}});var Nw=oy({conv3dTranspose_:function(e,t,n,r,a){var i=ay(e,"x","conv3dTranspose"),o=ay(t,"filter","conv3dTranspose");return kw(n,i,o,r,a)}});var Iw=oy({cos_:function(e){var t={x:ay(e,"x","cos")};return Jg.runKernel(Qv,t)}});var Sw=oy({cosh_:function(e){var t={x:ay(e,"x","cosh")};return Jg.runKernel("Cosh",t)}});var Tw=oy({cumsum_:function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=!1),void 0===r&&(r=!1);var a={x:ay(e,"x","cumsum")},i={axis:t,exclusive:n,reverse:r};return Jg.runKernel("Cumsum",a,i)}});var Cw=oy({denseBincount_:function(e,t,n,r){void 0===r&&(r=!1);var a=ay(e,"x","denseBincount"),i=ay(t,"weights","denseBincount");lv("int32"===a.dtype,(function(){return"Error in denseBincount: input dtype must be int32, but got "+a.dtype})),lv(a.rank<=2,(function(){return"Error in denseBincount: input must be at most rank 2, but got rank "+a.rank+"."})),lv(n>=0,(function(){return"size must be non-negative, but got "+n+"."})),lv(i.size===a.size||0===i.size,(function(){return"Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: "+a.shape+", weights shape: "+i.shape+"."}));var o={x:a,weights:i},s={size:n,binaryOutput:r};return Jg.runKernel("DenseBincount",o,s)}});var Ew=oy({depthToSpace_:function(e,t,n){void 0===n&&(n="NHWC");var r=ay(e,"x","depthToSpace"),a="NHWC"===n?r.shape[1]:r.shape[2],i="NHWC"===n?r.shape[2]:r.shape[3],o="NHWC"===n?r.shape[3]:r.shape[1];lv(a*t>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n    "+a+" and "+t+"  for depthToSpace with input shape\n    "+r.shape})),lv(i*t>=0,(function(){return"Negative dimension size caused by overflow when multiplying\n    "+i+" and "+t+" for depthToSpace with input shape\n        "+r.shape})),lv(o%(t*t)==0,(function(){return"Dimension size must be evenly divisible by "+t*t+" but is "+o+" for depthToSpace with input shape "+r.shape}));var s={x:r},u={blockSize:t,dataFormat:n};return Jg.runKernel("DepthToSpace",s,u)}});var Rw=oy({depthwiseConv2d_:function(e,t,n,r,a,i,o){void 0===a&&(a="NHWC"),void 0===i&&(i=[1,1]);var s=ay(e,"x","depthwiseConv2d"),u=ay(t,"filter","depthwiseConv2d"),l=s,c=!1;3===s.rank&&(c=!0,l=Jx(s,[1,s.shape[0],s.shape[1],s.shape[2]])),lv(4===l.rank,(function(){return"Error in depthwiseConv2d: input must be rank 4, but got rank "+l.rank+"."})),lv(4===u.rank,(function(){return"Error in depthwiseConv2d: filter must be rank 4, but got rank "+u.rank+"."})),lv(l.shape[3]===u.shape[2],(function(){return"Error in depthwiseConv2d: number of input channels ("+l.shape[3]+") must match the inChannels dimension in filter "+u.shape[2]+"."})),null!=o&&lv(mv(r),(function(){return"Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+r+"."}));var p={x:l,filter:u},h={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:o},f=Jg.runKernel("DepthwiseConv2dNative",p,h);return c?Jx(f,[f.shape[1],f.shape[2],f.shape[3]]):f}});var Aw=oy({diag_:function(e){var t={x:ay(e,"x","diag")};return Jg.runKernel("Diag",t)}});var Dw=oy({dilation2d_:function(e,t,n,r,a,i){void 0===a&&(a=[1,1]),void 0===i&&(i="NHWC");var o=ay(e,"x","dilation2d"),s=ay(t,"filter","dilation2d");lv(3===o.rank||4===o.rank,(function(){return"Error in dilation2d: input must be rank 3 or 4, but got rank "+o.rank+"."})),lv(3===s.rank,(function(){return"Error in dilation2d: filter must be rank 3, but got rank "+s.rank+"."})),lv("NHWC"===i,(function(){return"Error in dilation2d: Only NHWC is currently supported, but got dataFormat of "+i}));var u=o,l=!1;3===o.rank&&(u=Jx(o,[1,o.shape[0],o.shape[1],o.shape[2]]),l=!0);var c={x:u,filter:s},p={strides:n,pad:r,dilations:a},h=Jg.runKernel("Dilation2D",c,p);return l?Jx(h,[h.shape[1],h.shape[2],h.shape[3]]):h}});function Fw(e,t){for(var n=e.length,r=[],a=0;a<n;a++){var i=n-1-a,o=e[i]||1;(t[t.length-1-a]||1)>1&&1===o&&r.unshift(i)}return r}function _w(e,t){for(var n=[],r=0;r<t.length;r++){var a=e[e.length-r-1],i=t.length-r-1,o=t[i];(null==a||1===a&&o>1)&&n.unshift(i)}return n}function Ow(e,t){for(var n=[],r=Math.max(e.length,t.length),a=0;a<r;a++){var i=e[e.length-a-1];null==i&&(i=1);var o=t[t.length-a-1];if(null==o&&(o=1),1===i)n.unshift(o);else if(1===o)n.unshift(i);else{if(i!==o)throw Error("Operands could not be broadcast together with shapes "+e+" and "+t+".");n.unshift(i)}}return n}var Mw=oy({equal_:function(e,t){var n=ay(e,"a","equal"),r=ay(t,"b","equal"),a=Ug(n,r);n=a[0],r=a[1],Ow(n.shape,r.shape);var i={a:n,b:r};return Jg.runKernel("Equal",i)}});var Lw=oy({where_:function(e,t,n){var r=ay(t,"a","where"),a=ay(n,"b","where"),i=ay(e,"condition","where","bool"),o=Ow(r.shape,a.shape),s=cw(r,o),u=cw(a,o);1===i.rank&&lv(i.shape[0]===r.shape[0],(function(){return"The first dimension of `a` must match the size of `condition`."})),1!==i.rank&&cv(i.shape,u.shape,"Error in where: ");var l={condition:i,t:s,e:u};return Jg.runKernel("Select",l)}});var zw=oy({zerosLike_:function(e){var t={x:ay(e,"x","zerosLike")};return Jg.runKernel("ZerosLike",t)}});var Pw=oy({divNoNan_:function(e,t){var n=ay(e,"a","div"),r=ay(t,"b","div"),a=Ug(n,r);n=a[0],r=a[1];var i=kx(n,r),o=zw(i),s=Mw(r,o);return Lw(s,o,i)}});var Bw=oy({dot_:function(e,t){var n=ay(e,"t1","dot"),r=ay(t,"t2","dot");lv(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),(function(){return"Error in dot: inputs must all be rank 1 or 2, but got ranks "+n.rank+" and "+r.rank+"."}));var a=1===n.rank?n.size:n.shape[1],i=1===r.rank?r.size:r.shape[0];if(lv(a===i,(function(){return"Error in dot: inner dimensions of inputs must match, but got "+a+" and "+i+"."})),1===n.rank&&1===r.rank){var o=Jx(n,[1,-1]),s=Jx(r,[-1,1]),u=Ib(o,s);return Jx(u,[])}if(1===n.rank&&2===r.rank){var l=Jx(n,[1,-1]),c=Jx(r,[r.shape[0],r.shape[1]]),p=Ib(l,c);return Jx(p,[p.size])}if(2===n.rank&&1===r.rank){var h=Jx(r,[-1,1]),f=Ib(n,h);return Jx(f,[f.size])}var d=Jx(r,[r.shape[0],r.shape[1]]);return Ib(n,d)}});var Ww=oy({elu_:function(e){var t={x:ay(e,"x","elu")};return Jg.runKernel($v,t)}});var Vw=oy({erf_:function(e){var t=ay(e,"x","erf");lv("int32"===t.dtype||"float32"===t.dtype,(function(){return"Input dtype must be `int32` or `float32`."})),"int32"===t.dtype&&(t=rb(t,"float32"));var n={x:t};return Jg.runKernel(eg,n)}});var Uw=oy({exp_:function(e){var t={x:ay(e,"x","exp")};return Jg.runKernel(tg,t)}});var Gw=oy({expandDims_:function(e,t){void 0===t&&(t=0);var n=ay(e,"x","expandDims",null);lv(t<=n.rank,(function(){return"Axis must be <= rank of the tensor"}));var r={input:n},a={dim:t};return Jg.runKernel("ExpandDims",r,a)}});var jw=oy({expm1_:function(e){var t={x:ay(e,"x","expm1")};return Jg.runKernel("Expm1",t)}});var Hw=oy({tile_:function(e,t){var n=ay(e,"x","tile",null);lv(n.rank===t.length,(function(){return"Error in transpose: rank of input "+n.rank+" must match length of reps "+t+"."}));var r={x:n},a={reps:t};return Jg.runKernel("Tile",r,a)}});var qw=oy({eye_:function(e,t,n,r){void 0===r&&(r="float32"),null==t&&(t=e);for(var a=nb([e,t],r),i=e<=t?e:t,o=0;o<i;++o)a.set(1,o,o);var s=Jx(a.toTensor(),[e,t]);if(null==n)return s;if(1===n.length)return Hw(Gw(s,0),[n[0],1,1]);if(2===n.length)return Hw(Gw(Gw(s,0),0),[n[0],n[1],1,1]);if(3===n.length)return Hw(Gw(Gw(Gw(s,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error("eye() currently supports only 1D and 2D batchShapes, but received "+n.length+"D.")}});function Kw(e,t,n){var r={shape:e,value:t,dtype:n};return Jg.runKernel("Fill",{},r)}var Xw=oy({floor_:function(e){var t={x:ay(e,"x","floor")};return Jg.runKernel("Floor",t)}});var Yw=oy({gather_:function(e,t,n,r){void 0===n&&(n=0),void 0===r&&(r=0);var a={x:ay(e,"x","gather"),indices:ay(t,"indices","gather","int32")},i={axis:n,batchDims:r};return Jg.runKernel("GatherV2",a,i)}});var Jw=oy({greater_:function(e,t){var n=ay(e,"a","greater"),r=ay(t,"b","greater"),a=Ug(n,r);n=a[0],r=a[1],Ow(n.shape,r.shape);var i={a:n,b:r};return Jg.runKernel("Greater",i)}});var Zw=oy({greaterEqual_:function(e,t){var n=ay(e,"a","greaterEqual"),r=ay(t,"b","greaterEqual"),a=Ug(n,r);n=a[0],r=a[1],Ow(n.shape,r.shape);var i={a:n,b:r};return Jg.runKernel("GreaterEqual",i)}});var Qw=oy({imag_:function(e){var t={input:ay(e,"input","imag")};return Jg.runKernel("Imag",t)}});var $w=oy({isFinite_:function(e){var t={x:ay(e,"x","isFinite")};return Jg.runKernel("IsFinite",t)}});var ek=oy({isInf_:function(e){var t={x:ay(e,"x","isInf")};return Jg.runKernel("IsInf",t)}});var tk=oy({isNaN_:function(e){var t={x:ay(e,"x","isNaN")};return Jg.runKernel("IsNan",t)}});var nk=oy({leakyRelu_:function(e,t){void 0===t&&(t=.2);var n={x:ay(e,"x","leakyRelu")},r={alpha:t};return Jg.runKernel("LeakyRelu",n,r)}});var rk=oy({less_:function(e,t){var n=ay(e,"a","less"),r=ay(t,"b","less"),a=Ug(n,r);n=a[0],r=a[1],Ow(n.shape,r.shape);var i={a:n,b:r};return Jg.runKernel("Less",i)}});var ak=oy({lessEqual_:function(e,t){var n=ay(e,"a","lessEqual"),r=ay(t,"b","lessEqual"),a=Ug(n,r);n=a[0],r=a[1],Ow(n.shape,r.shape);var i={a:n,b:r};return Jg.runKernel("LessEqual",i)}});function ik(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");var r={start:e,stop:t,num:n};return Jg.runKernel("LinSpace",{},r)}var ok=oy({localResponseNormalization_:function(e,t,n,r,a){void 0===t&&(t=5),void 0===n&&(n=1),void 0===r&&(r=1),void 0===a&&(a=.5);var i=ay(e,"x","localResponseNormalization");lv(4===i.rank||3===i.rank,(function(){return"Error in localResponseNormalization: x must be rank 3 or 4 but got\n               rank "+i.rank+"."})),lv(mv(t),(function(){return"Error in localResponseNormalization: depthRadius must be an integer but got depthRadius "+t+"."}));var o=i,s=!1;3===i.rank&&(s=!0,o=Jx(i,[1,i.shape[0],i.shape[1],i.shape[2]]));var u={x:o},l={depthRadius:t,bias:n,alpha:r,beta:a},c=Jg.runKernel("LRN",u,l);return s?Jx(c,[c.shape[1],c.shape[2],c.shape[3]]):c}});var sk=oy({log_:function(e){var t={x:ay(e,"x","log")};return Jg.runKernel(ng,t)}});var uk=oy({log1p_:function(e){var t={x:ay(e,"x","log1p")};return Jg.runKernel("Log1p",t)}});function lk(e,t){lv(Ov(e),(function(){return"The f passed in variableGrads(f) must be a function"})),lv(null==t||Array.isArray(t)&&t.every((function(e){return e instanceof Pg})),(function(){return"The varList passed in variableGrads(f, varList) must be an array of variables"}));var n=null!=t;if(!n)for(var r in t=[],Jg.registeredVariables)t.push(Jg.registeredVariables[r]);var a=n?t.filter((function(e){return!e.trainable})):null,i=t.length;lv((t=t.filter((function(e){return e.trainable}))).length>0,(function(){return"variableGrads() expects at least one of the input variables to be trainable, but none of the "+i+" variables is trainable."}));var o=Jg.gradients(e,t,null,!0),s=o.value,u=o.grads;lv(u.some((function(e){return null!=e})),(function(){return"Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize()."})),lv(0===s.rank,(function(){return"The f passed in variableGrads(f) must return a scalar, but it returned a rank-"+s.rank+" tensor"}));var l={};return t.forEach((function(e,t){null!=u[t]&&(l[e.name]=u[t])})),null!=a&&a.forEach((function(e){return l[e.name]=null})),{value:s,grads:l}}function ck(e){return Jg.customGrad(e)}function pk(e){if(e.filter((function(e){return null==e})).length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n    the f you passed encloses all operations that lead from x to y.")}var hk=oy({neg_:function(e){var t={x:ay(e,"x","neg")};return Jg.runKernel("Neg",t)}});var fk=oy({softplus_:function(e){var t={x:ay(e,"x","softplus")};return Jg.runKernel("Softplus",t)}});var dk=oy({logSigmoid_:function(e){var t=ay(e,"x","logSigmoid");return ck((function(e){return{value:hk(fk(hk(e))),gradFunc:function(t){return Nx(t,ew(hk(e)))}}}))(t)}});var mk=oy({max_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r={x:ay(e,"x","max")},a={reductionIndices:t,keepDims:n};return Jg.runKernel("Max",r,a)}});var vk=oy({sub_:function(e,t){var n=ay(e,"a","sub"),r=ay(t,"b","sub"),a=Ug(n,r),i={a:n=a[0],b:r=a[1]};return Jg.runKernel(og,i)}});var gk=oy({sum_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=ay(e,"x","sum");"bool"===r.dtype&&(r=rb(r,"int32"));var a={x:r},i={axis:t,keepDims:n};return Jg.runKernel("Sum",a,i)}});var yk=oy({logSoftmax_:function(e,t){void 0===t&&(t=-1);var n=ay(e,"logits","logSoftmax");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and axis was "+t);return ck((function(e,n){var r=mk(e,t,!0),a=vk(e,r),i=vk(rb(a,"float32"),sk(gk(Uw(a),t,!0)));n([i]);return{value:i,gradFunc:function(e,n){var r=n[0],a=Uw(r);return vk(e,Nx(gk(e,t,!0),a))}}}))(n)}});function bk(e,t){for(var n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function xk(e,t,n){for(var r=e.length+t.length,a=[],i=0,o=0,s=0;s<r;s++)-1===n.indexOf(s)?a.push(e[i++]):a.push(t[o++]);return a}function wk(e,t){for(var n=[],r=e.length,a=0;a<r;a++)-1===t.indexOf(a)&&n.push(e[a]);return[n,t.map((function(t){return e[t]}))]}function kk(e,t){return xk(e,t.map((function(e){return 1})),t)}function Nk(e,t,n){lv(bk(t,n),(function(){return e+" supports only inner-most axes for now. Got axes "+t+" and rank-"+n+" input."}))}function Ik(e,t){if(bk(e,t))return null;for(var n=[],r=0;r<t;++r)-1===e.indexOf(r)&&n.push(r);return e.forEach((function(e){return n.push(e)})),n}function Sk(e){return e.map((function(e,t){return[t,e]})).sort((function(e,t){return e[1]-t[1]})).map((function(e){return e[0]}))}function Tk(e,t){for(var n=[],r=t-e;r<t;++r)n.push(r);return n}var Ck=oy({logSumExp_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=ay(e,"x","logSumExp"),a=xv(t,r.shape),i=mk(r,a,!0),o=vk(r,i),s=Uw(o),u=gk(s,a),l=sk(u),c=xx(Jx(i,l.shape),l);if(n){var p=kk(c.shape,a);return Jx(c,p)}return c}});var Ek=oy({logicalAnd_:function(e,t){var n=ay(e,"a","logicalAnd","bool"),r=ay(t,"b","logicalAnd","bool");Ow(n.shape,r.shape);var a={a:n,b:r};return Jg.runKernel("LogicalAnd",a)}});var Rk=oy({logicalNot_:function(e){var t={x:ay(e,"x","logicalNot","bool")};return Jg.runKernel("LogicalNot",t)}});var Ak=oy({logicalOr_:function(e,t){var n=ay(e,"a","logicalOr","bool"),r=ay(t,"b","logicalOr","bool");Ow(n.shape,r.shape);var a={a:n,b:r};return Jg.runKernel("LogicalOr",a)}});var Dk=oy({logicalXor_:function(e,t){var n=ay(e,"a","logicalXor","bool"),r=ay(t,"b","logicalXor","bool");return Ow(n.shape,r.shape),Ek(Ak(e,t),Rk(Ek(e,t)))}});var Fk=oy({maxPool_:function(e,t,n,r,a){var i=ay(e,"x","maxPool"),o=i,s=!1;3===i.rank&&(s=!0,o=Jx(i,[1,i.shape[0],i.shape[1],i.shape[2]])),lv(4===o.rank,(function(){return"Error in maxPool: input must be rank 4 but got rank "+o.rank+"."})),lv(Xx(n,1),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '1'"})),null!=a&&lv(mv(r),(function(){return"Error in maxPool: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+"."}));var u={x:o},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a},c=Jg.runKernel("MaxPool",u,l);return s?Jx(c,[c.shape[1],c.shape[2],c.shape[3]]):c}});var _k=oy({maxPool3d_:function(e,t,n,r,a,i,o){void 0===t&&(t=[1,1,1]),void 0===i&&(i="NDHWC"),null==o?o=[1,1,1]:px("dilations is deprecated, this field will be gone in v3.0.0.");var s=ay(e,"x","maxPool3d"),u=s,l=!1;4===s.rank&&(l=!0,u=Jx(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),lv(5===u.rank,(function(){return"Error in maxPool3d: x must be rank 5 but got rank "+u.rank+"."})),lv("NDHWC"===i,(function(){return"Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of "+i})),lv(Xx(n,o),(function(){return"Error in maxPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+o+"'"})),null!=a&&lv(mv(r),(function(){return"Error in maxPool3d: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+"."}));var c={x:u},p={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i,dilations:o},h=Jg.runKernel("MaxPool3D",c,p);return l?Jx(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}});var Ok=oy({maxPoolWithArgmax_:function(e,t,n,r,a){void 0===a&&(a=!1);var i={x:ay(e,"x","maxPoolWithArgmax")},o={filterSize:t,strides:n,pad:r,includeBatchInIndex:a},s=Jg.runKernel("MaxPoolWithArgmax",i,o);return{result:s[0],indexes:s[1]}}});var Mk=oy({maximum_:function(e,t){var n=ay(e,"a","maximum"),r=ay(t,"b","maximum"),a=Ug(n,r);n=a[0],r=a[1],"bool"===n.dtype&&(n=rb(n,"int32"),r=rb(r,"int32")),Ow(n.shape,r.shape);var i={a:n,b:r};return Jg.runKernel("Maximum",i)}});var Lk=oy({mean_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r={x:ay(e,"x","mean")},a={axis:t,keepDims:n};return Jg.runKernel("Mean",r,a)}});var zk=oy({min_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r={x:ay(e,"x","min")},a={axis:t,keepDims:n};return Jg.runKernel("Min",r,a)}});var Pk=oy({minimum_:function(e,t){var n=ay(e,"a","minimum"),r=ay(t,"b","minimum"),a=Ug(n,r);n=a[0],r=a[1],"bool"===n.dtype&&(n=rb(n,"int32"),r=rb(r,"int32")),Ow(n.shape,r.shape);var i={a:n,b:r};return Jg.runKernel("Minimum",i)}});var Bk=oy({mirrorPad_:function(e,t,n){lv("reflect"===n||"symmetric"===n,(function(){return"Invalid mode. Mode must be either reflect or symmetric. Got "+n+"."}));var r=ay(e,"x","mirrorPad");if(0===r.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");lv(t.length===r.rank,(function(){return"Padding doesn't match input. Must be "+r.rank+". Got "+t.length+"."}));for(var a="reflect"===n?1:0,i=function(e){lv(2===t[e].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),lv(t[e][0]>=0&&t[e][0]<=r.shape[e]-a&&t[e][1]>=0&&t[e][1]<=r.shape[e]-a,(function(){return"Padding in dimension "+e+" cannot be greater than or equal to "+(r.shape[e]-a)+" or less than 0 for input of shape "+r.shape}))},o=0;o<r.rank;o++)i(o);var s={paddings:t,mode:n},u={x:r};return Jg.runKernel("MirrorPad",u,s)}});var Wk=oy({mod_:function(e,t){var n=ay(e,"a","mod"),r=ay(t,"b","mod"),a=Ug(n,r),i={a:n=a[0],b:r=a[1]};return Jg.runKernel(rg,i)}});var Vk=oy({square_:function(e){var t=ay(e,"x","square");return Jg.runKernel("Square",{x:t},{})}});var Uk=oy({moments_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=xv(t,(e=ay(e,"x","moments")).shape),a=Lk(e,r,n),i=a.shape;n||(i=kk(a.shape,r));var o=Vk(vk(rb(e,"float32"),Jx(a,i)));return{mean:a,variance:Lk(o,r,n)}}});var Gk=oy({multiRNNCell_:function(e,t,n,r){for(var a=ay(t,"data","multiRNNCell"),i=iy(n,"c","multiRNNCell"),o=iy(r,"h","multiRNNCell"),s=a,u=[],l=0;l<e.length;l++){var c=e[l](s,i[l],o[l]);u.push(c[0]),u.push(c[1]),s=c[1]}for(var p=[],h=[],f=0;f<u.length;f+=2)p.push(u[f]),h.push(u[f+1]);return[p,h]}});var jk=oy({multinomial_:function(e,t,n,r){void 0===r&&(r=!1);var a=ay(e,"logits","multinomial"),i=a.size,o=a.rank;if(i<2)throw new Error("Error in multinomial: you need at least 2 outcomes, but got "+i+".");if(o>2)throw new Error("Rank of probabilities must be 1 or 2, but is "+o);n=n||Math.random();var s={logits:1===o?Jx(a,[1,-1]):a},u={numSamples:t,seed:n,normalized:r},l=Jg.runKernel("Multinomial",s,u);return 1===o?Jx(l,[l.size]):l}});var Hk=oy({notEqual_:function(e,t){var n=ay(e,"a","notEqual"),r=ay(t,"b","notEqual"),a=Ug(n,r);n=a[0],r=a[1],Ow(n.shape,r.shape);var i={a:n,b:r};return Jg.runKernel("NotEqual",i)}});function qk(e,t){if(void 0===t&&(t="float32"),"complex64"===t){var n=qk(e,"float32"),r=qk(e,"float32");return sy(n,r)}var a=Bv(fv(e),t);return Jg.makeTensor(a,e,t)}function Kk(e,t){if(void 0===t&&(t="float32"),"complex64"===t){var n=Kk(e,"float32"),r=qk(e,"float32");return sy(n,r)}var a=Pv(fv(e),t);return Jg.makeTensor(a,e,t)}var Xk=oy({onesLike_:function(e){var t={x:ay(e,"x","onesLike")};return Jg.runKernel("OnesLike",t)}});var Yk=oy({outerProduct_:function(e,t){var n=ay(e,"v1","outerProduct"),r=ay(t,"v2","outerProduct");lv(1===n.rank&&1===r.rank,(function(){return"Error in outerProduct: inputs must be rank 1, but got ranks "+n.rank+" and "+r.rank+"."}));var a=Jx(n,[-1,1]),i=Jx(r,[1,-1]);return Ib(a,i)}});var Jk=oy({pad_:function(e,t,n){void 0===n&&(n=0);var r=ay(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var a={paddings:t,constantValue:n},i={x:r};return Jg.runKernel("PadV2",i,a)}});var Zk=oy({pad1d_:function(e,t,n){return void 0===n&&(n=0),lv(2===t.length,(function(){return"Invalid number of paddings. Must be length of 2."})),Jk(e,[t],n)}});var Qk=oy({pad2d_:function(e,t,n){return void 0===n&&(n=0),lv(2===t.length&&2===t[0].length&&2===t[1].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),Jk(e,t,n)}});var $k=oy({pad3d_:function(e,t,n){return void 0===n&&(n=0),lv(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),Jk(e,t,n)}});var eN=oy({pad4d_:function(e,t,n){return void 0===n&&(n=0),lv(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,(function(){return"Invalid number of paddings. Must be length of 2 each."})),Jk(e,t,n)}});var tN=oy({spaceToBatchND_:function(e,t,n){var r=ay(e,"x","spaceToBatchND");lv(r.rank>=1+t.length,(function(){return"input rank "+r.rank+" should be > than [blockShape] "+t.length})),lv(n.length===t.length,(function(){return"paddings.shape[0] "+n.length+" must be equal to [blockShape] "+t.length})),lv(r.shape.reduce((function(e,r,a){return a>0&&a<=t.length?e&&(r+n[a-1][0]+n[a-1][1])%t[a-1]==0:e}),!0),(function(){return"input spatial dimensions "+r.shape.slice(1)+" with paddings "+n.toString()+" must be divisible by blockShapes "+t.toString()}));var a={x:r},i={blockShape:t,paddings:n};return Jg.runKernel("SpaceToBatchND",a,i)}});var nN=oy({pool_:function(e,t,n,r,a,i){null==a&&(a=[1,1]),null==i&&(i=1),0===r&&(r="valid");var o=ay(e,"x","maxPool"),s=o,u=!1;3===o.rank&&(u=!0,s=Jx(o,[1,o.shape[0],o.shape[1],o.shape[2]])),lv(Xx(i,a),(function(){return"Error in pool: Either strides or dilations must be 1. Got strides "+i+" and dilations '"+a+"'"}));var l,c=Px(s.shape,t,i,a,r),p=[c.dilationHeight,c.dilationWidth];l="same"===r?function(e,t){var n=e.map((function(e,n){return e+(e-1)*(t[n]-1)})).map((function(e){return e-1})),r=n.map((function(e){return Math.floor(e/2)})),a=n.map((function(e,t){return e-r[t]}));return n.map((function(e,t){return[r[t],a[t]]}))}([c.filterHeight,c.filterWidth],p):[[0,0],[0,0]];var h=1===p[0]&&1===p[1],f=function(e,t,n){var r=n.map((function(e){return e[0]})),a=n.map((function(e){return e[1]})),i=e.concat(r,a),o=t.map((function(e,t){return(e-i[t]%e)%e})),s=a.map((function(e,t){return e+o[t]})),u=t.map((function(e,t){return[r[t],s[t]]})),l=t.map((function(e,t){return[0,o[t]]}));return[u,l]}([c.inHeight,c.inWidth],p,l),d=f[0],m=f[1],v=h?r:"valid",g=h?s:tN(s,p,d),y=("avg"===n?function(){return Zx(g,t,i,v)}:function(){return Fk(g,t,i,v)})(),b=h?y:aw(y,p,m);return u?Jx(b,[b.shape[1],b.shape[2],b.shape[3]]):b}});var rN=oy({pow_:function(e,t){var n=ay(e,"base","pow"),r=ay(t,"exp","pow"),a=Ug(n,r),i={a:n=a[0],b:r=a[1]};return Jg.runKernel(ag,i)}});var aN=oy({prelu_:function(e,t){var n={x:ay(e,"x","prelu"),alpha:ay(t,"alpha","prelu")};return Jg.runKernel("Prelu",n)}});var iN=oy({prod_:function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);var r=ay(e,"x","prod");"bool"===r.dtype&&(r=rb(r,"int32"));var a={x:r},i={axis:t,keepDims:n};return Jg.runKernel("Prod",a,i)}});var oN=oy({rand_:function(e,t,n){var r=fv(e),a=null;if(null==n||"float32"===n)a=new Float32Array(r);else if("int32"===n)a=new Int32Array(r);else{if("bool"!==n)throw new Error("Unknown data type "+n);a=new Uint8Array(r)}for(var i=0;i<r;i++)a[i]=t();return Jg.makeTensor(a,e,n)}}),sN=n((function(e){!function(e,t,n){function r(e){var t,n=this,r=(t=4022871197,function(e){e=e.toString();for(var n=0;n<e.length;n++){var r=.02519603282416938*(t+=e.charCodeAt(n));r-=t=r>>>0,t=(r*=t)>>>0,t+=4294967296*(r-=t)}return 2.3283064365386963e-10*(t>>>0)});n.next=function(){var e=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=e-(n.c=0|e)},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(e),n.s0<0&&(n.s0+=1),n.s1-=r(e),n.s1<0&&(n.s1+=1),n.s2-=r(e),n.s2<0&&(n.s2+=1),r=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function i(e,t){var n=new r(e),i=t&&t.state,o=n.next;return o.int32=function(){return 4294967296*n.next()|0},o.double=function(){return o()+11102230246251565e-32*(2097152*o()|0)},o.quick=o,i&&("object"==typeof i&&a(i,n),o.state=function(){return a(n,{})}),o}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.alea=i}(0,e,!1)})),uN=n((function(e){!function(e,t,n){function r(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function i(e,t){var n=new r(e),i=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&a(i,n),o.state=function(){return a(n,{})}),o}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.xor128=i}(0,e,!1)})),lN=n((function(e){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),r==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function i(e,t){var n=new r(e),i=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&a(i,n),o.state=function(){return a(n,{})}),o}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.xorwow=i}(0,e,!1)})),cN=n((function(e){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n<t.length;++n)r[7&n]=r[7&n]<<15^t.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],e.x=r,e.i=0,n=256;n>0;--n)e.next()}(t,e)}function a(e,t){return t.x=e.x.slice(),t.i=e.i,t}function i(e,t){null==e&&(e=+new Date);var n=new r(e),i=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,i&&(i.x&&a(i,n),o.state=function(){return a(n,{})}),o}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.xorshift7=i}(0,e,!1)})),pN=n((function(e){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,i=t.i;return t.w=r=r+1640531527|0,n=a[i+34&127],e=a[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[i]=n^e,t.i=i,n+(r^r>>>16)|0},function(e,t){var n,r,a,i,o,s=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,i=-32;i<u;++i)t&&(r^=t.charCodeAt((i+32)%t.length)),0===i&&(o=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,i>=0&&(o=o+1640531527|0,a=0==(n=s[127&i]^=r+o)?a+1:0);for(a>=128&&(s[127&(t&&t.length||0)]=-1),a=127,i=512;i>0;--i)r=s[a+34&127],n=s[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[a]=r^n;e.w=o,e.X=s,e.i=a}(t,e)}function a(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function i(e,t){null==e&&(e=+new Date);var n=new r(e),i=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,i&&(i.X&&a(i,n),o.state=function(){return a(n,{})}),o}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.xor4096=i}(0,e,!1)})),hN=n((function(e){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r<n.length+20;r++)t.b^=0|n.charCodeAt(r),t.next()}function a(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function i(e,t){var n=new r(e),i=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},o.int32=n.next,o.quick=o,i&&("object"==typeof i&&a(i,n),o.state=function(){return a(n,{})}),o}t&&t.exports?t.exports=i:n&&n.amd?n((function(){return i})):this.tychei=i}(0,e,!1)})),fN=n((function(e){!function(t,n){var r,a=this,i=n.pow(256,6),o=n.pow(2,52),s=2*o;function u(e,u,f){var d=[],m=p(function e(t,n){var r,a=[],i=typeof t;if(n&&"object"==i)for(r in t)try{a.push(e(t[r],n-1))}catch(e){}return a.length?a:"string"==i?t:t+"\0"}((u=1==u?{entropy:!0}:u||{}).entropy?[e,h(t)]:null==e?function(){try{var e;return r&&(e=r.randomBytes)?e=e(256):(e=new Uint8Array(256),(a.crypto||a.msCrypto).getRandomValues(e)),h(e)}catch(e){var n=a.navigator,i=n&&n.plugins;return[+new Date,a,i,a.screen,h(t)]}}():e,3),d),v=new l(d),g=function(){for(var e=v.g(6),t=i,n=0;e<o;)e=256*(e+n),t*=256,n=v.g(1);for(;e>=s;)e/=2,t/=2,n>>>=1;return(e+n)/t};return g.int32=function(){return 0|v.g(4)},g.quick=function(){return v.g(4)/4294967296},g.double=g,p(h(v.S),t),(u.pass||f||function(e,t,r,a){return a&&(a.S&&c(a,v),e.state=function(){return c(v,{})}),r?(n.random=e,t):e})(g,m,"global"in u?u.global:this==n,u.state)}function l(e){var t,n=e.length,r=this,a=0,i=r.i=r.j=0,o=r.S=[];for(n||(e=[n++]);a<256;)o[a]=a++;for(a=0;a<256;a++)o[a]=o[i=255&i+e[a%n]+(t=o[a])],o[i]=t;(r.g=function(e){for(var t,n=0,a=r.i,i=r.j,o=r.S;e--;)t=o[a=255&a+1],n=256*n+o[255&(o[a]=o[i=255&i+t])+(o[i]=t)];return r.i=a,r.j=i,n})(256)}function c(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function p(e,t){for(var n,r=e+"",a=0;a<r.length;)t[255&a]=255&(n^=19*t[255&a])+r.charCodeAt(a++);return h(t)}function h(e){return String.fromCharCode.apply(0,e)}if(n.seedrandom=u,p(n.random(),t),e.exports){e.exports=u;try{r=require("crypto")}catch(e){}}else 0}([],Math)}));fN.alea=sN,fN.xor128=uN,fN.xorwow=lN,fN.xorshift7=cN,fN.xor4096=pN,fN.tychei=hN;var dN=fN.alea,mN=function(){function e(e,t,n,r,a){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);var i=a||Math.random();this.random=dN(i.toString())}var t=e.prototype;return t.nextValue=function(){if(!isNaN(this.nextVal)){var e=this.nextVal;return this.nextVal=NaN,e}for(var t,n,r=!1;!r;){var a=void 0,i=void 0,o=void 0;do{o=(a=2*this.random()-1)*a+(i=2*this.random()-1)*i}while(o>=1||0===o);var s=Math.sqrt(-2*Math.log(o)/o);t=this.mean+this.stdDev*a*s,n=this.mean+this.stdDev*i*s,this.truncated&&!this.isValidTruncated(t)||(r=!0)}return this.truncated&&!this.isValidTruncated(n)||(this.nextVal=this.convertValue(n)),this.convertValue(t)},t.convertValue=function(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)},t.isValidTruncated=function(e){return e<=this.upper&&e>=this.lower},e}(),vN=function(){function e(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;var a=r||Math.random();this.randu=dN(a.toString()),this.randn=new mN(0,1,n,!1,this.randu()),this.d=e<1?e+2/3:e-1/3,this.c=1/Math.sqrt(9*this.d)}var t=e.prototype;return t.nextValue=function(){for(var e,t,n,r,a,i;;){do{r=this.randn.nextValue(),i=1+this.c*r}while(i<=0);if(i*=i*i,t=1-.331*(e=r*r)*e,n=.5*e+this.d*(1-i+Math.log(i)),(a=this.randu())<t||Math.log(a)<n)break}return i=1/this.beta*this.d*i,this.alpha<1&&(i*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(i)},t.convertValue=function(e){return"float32"===this.dtype?e:Math.round(e)},e}(),gN=function(){function e(e,t,n,r){var a=this;if(void 0===e&&(e=0),void 0===t&&(t=1),this.canReturnFloat=function(){return null==a.dtype||"float32"===a.dtype},this.min=e,this.range=t-e,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error("The difference between "+e+" - "+t+" <= 1 and dtype is not float");this.random=dN(r)}var t=e.prototype;return t.convertValue=function(e){return this.canReturnFloat()?e:Math.round(e)},t.nextValue=function(){return this.convertValue(this.min+this.range*this.random())},e}();var yN=oy({randomGamma_:function(e,t,n,r,a){if(void 0===n&&(n=1),void 0===r&&(r="float32"),null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error("Unsupported data type "+r);for(var i=new vN(t,n,r,a),o=nb(e,r),s=0;s<o.values.length;s++)o.values[s]=i.nextValue();return o.toTensor()}});var bN=oy({randomNormal_:function(e,t,n,r,a){if(void 0===t&&(t=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type "+r);for(var i=new mN(t,n,r,!1,a),o=nb(e,r),s=0;s<o.values.length;s++)o.values[s]=i.nextValue();return o.toTensor()}});var xN=oy({randomUniform_:function(e,t,n,r,a){void 0===t&&(t=0),void 0===n&&(n=1),void 0===r&&(r="float32");for(var i=nb(e,r),o=new gN(t,n,null,a),s=0;s<i.values.length;s++)i.values[s]=o.nextValue();return i.toTensor()}});function wN(e,t,n,r){if(void 0===n&&(n=1),void 0===r&&(r="float32"),0===n)throw new Error("Cannot have a step of zero");var a={start:e,stop:t,step:n,dtype:r};return Jg.runKernel("Range",{},a)}var kN=oy({real_:function(e){var t={input:ay(e,"input","real")};return Jg.runKernel("Real",t)}});var NN=oy({reciprocal_:function(e){var t={x:ay(e,"x","reciprocal")};return Jg.runKernel("Reciprocal",t)}});var IN=oy({relu_:function(e){var t={x:ay(e,"x","relu")};return Jg.runKernel("Relu",t)}});var SN=oy({relu6_:function(e){var t={x:ay(e,"x","relu6")};return Jg.runKernel("Relu6",t)}});var TN=oy({reverse_:function(e,t){var n={x:ay(e,"x","reverse")},r={dims:t};return Jg.runKernel("Reverse",n,r)}});var CN=oy({reverse1d_:function(e){var t=ay(e,"x","reverse");return lv(1===t.rank,(function(){return"Error in reverse1D: x must be rank 1 but got rank "+t.rank+"."})),TN(t,0)}});var EN=oy({reverse2d_:function(e,t){var n=ay(e,"x","reverse");return lv(2===n.rank,(function(){return"Error in reverse2D: x must be rank 2 but got rank "+n.rank+"."})),TN(n,t)}});var RN=oy({reverse3d_:function(e,t){var n=ay(e,"x","reverse");return lv(3===n.rank,(function(){return"Error in reverse3D: x must be rank 3 but got rank "+n.rank+"."})),TN(n,t)}});var AN=oy({reverse4d_:function(e,t){var n=ay(e,"x","reverse");return lv(4===n.rank,(function(){return"Error in reverse4D: x must be rank 4 but got rank "+n.rank+"."})),TN(n,t)}});var DN=oy({round_:function(e){var t={x:ay(e,"x","round")};return Jg.runKernel("Round",t)}});var FN=oy({rsqrt_:function(e){var t={x:ay(e,"x","rsqrt")};return Jg.runKernel("Rsqrt",t)}});function _N(e,t){if((Cv(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&Cv(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return uy(e,[],[],t)}var ON=oy({selu_:function(e){var t={x:ay(e,"x","selu")};return Jg.runKernel("Selu",t)}});var MN=oy({separableConv2d_:function(e,t,n,r,a,i,o){void 0===i&&(i=[1,1]),void 0===o&&(o="NHWC");var s=ay(e,"x","separableConv2d"),u=ay(t,"depthwiseFilter","separableConv2d"),l=ay(n,"pointwiseFilter","separableConv2d"),c=s,p=!1;if(3===s.rank&&(p=!0,c=Jx(s,[1,s.shape[0],s.shape[1],s.shape[2]])),"NCHW"===o)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");lv(4===c.rank,(function(){return"Error in separableConv2d: input must be rank 4, but got rank "+c.rank+"."})),lv(4===u.rank,(function(){return"Error in separableConv2d: depthwise filter must be rank 4, but got rank "+u.rank+"."})),lv(4===l.rank,(function(){return"Error in separableConv2d: pointwise filter must be rank 4, but got rank "+u.rank+"."})),lv(1===l.shape[0],(function(){return"Error in separableConv2d: the first dimension of pointwise filter  must be 1, but got "+l.shape[0]+"."})),lv(1===l.shape[1],(function(){return"Error in separableConv2d: the second dimension of pointwise filter must be 1, but got "+l.shape[1]+"."}));var h=u.shape[2],f=u.shape[3];lv(l.shape[2]===h*f,(function(){return"Error in separableConv2d: the third dimension of pointwise filter must be "+h*f+", but got "+l.shape[2]+"."}));var d=Rw(c,u,r,a,o,i),m=gw(d,l,1,"valid",o);return p?Jx(m,[m.shape[1],m.shape[2],m.shape[3]]):m}});function LN(){return(LN=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i,o,s,u,l,c,p,h,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=ay(t,"x","setdiff1d"),a=ay(n,"y","setdiff1d"),lv(r.dtype===a.dtype,(function(){return"x and y should have the same dtype, but got x ("+r.dtype+") and y ("+a.dtype+")."})),lv(1===r.rank,(function(){return"x should be 1D tensor, but got x ("+r.shape+")."})),lv(1===a.rank,(function(){return"y should be 1D tensor, but got y ("+a.shape+")."})),e.next=7,r.data();case 7:return i=e.sent,e.next=10,a.data();case 10:for(o=e.sent,s=new Set(o),u=0,l=0;l<i.length;l++)s.has(i[l])||u++;for(c=new Rg([u],r.dtype),p=new Rg([u],"int32"),h=0,f=0;h<i.length;h++)s.has(i[h])||(c.values[f]=i[h],p.values[f]=h,f++);return e.abrupt("return",[c.toTensor(),p.toTensor()]);case 18:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var zN=function(e,t){return LN.apply(this,arguments)};var PN=oy({sign_:function(e){var t={x:ay(e,"x","sign")};return Jg.runKernel("Sign",t)}});var BN=oy({sin_:function(e){var t={x:ay(e,"x","sin")};return Jg.runKernel(ig,t)}});var WN=oy({sinh_:function(e){var t={x:ay(e,"x","sinh")};return Jg.runKernel("Sinh",t)}});var VN=oy({slice1d_:function(e,t,n){var r=ay(e,"x","slice1d");return lv(1===r.rank,(function(){return"slice1d expects a rank-1 tensor, but got a rank-"+r.rank+" tensor"})),tw(r,[t],[n])}});var UN=oy({slice2d_:function(e,t,n){var r=ay(e,"x","slice2d");return lv(2===r.rank,(function(){return"slice2d expects a rank-2 tensor, but got a rank-"+r.rank+" tensor"})),tw(r,t,n)}});var GN=oy({slice3d_:function(e,t,n){var r=ay(e,"x","slice3d");return lv(3===r.rank,(function(){return"slice3d expects a rank-3 tensor, but got a rank-"+r.rank+" tensor"})),tw(r,t,n)}});var jN=oy({slice4d_:function(e,t,n){var r=ay(e,"x","slice4d");return lv(4===r.rank,(function(){return"slice4d expects a rank-4 tensor, but got a rank-"+r.rank+" tensor"})),tw(r,t,n)}});var HN=oy({softmax_:function(e,t){void 0===t&&(t=-1);var n=ay(e,"logits","softmax","float32");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error("Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and dim was "+t);var r={logits:n},a={dim:t};return Jg.runKernel("Softmax",r,a)}});var qN=oy({fft_:function(e){lv("complex64"===e.dtype,(function(){return"The dtype for tf.spectral.fft() must be complex64 but got "+e.dtype+"."}));var t={input:e};return Jg.runKernel("FFT",t)}});var KN=oy({ifft_:function(e){lv("complex64"===e.dtype,(function(){return"The dtype for tf.spectral.ifft() must be complex64 but got "+e.dtype+"."}));var t={input:e};return Jg.runKernel("IFFT",t)}});var XN=oy({irfft_:function(e){var t,n=e.shape[e.shape.length-1],r=e.size/n;if(n<=2){var a=Jx(e,[r,n]);t=KN(a)}else{var i=[r,2*(n-1)],o=Jx(kN(e),[r,n]),s=Jx(Qw(e),[r,n]),u=TN(tw(o,[0,1],[r,n-2]),1),l=Nx(TN(tw(s,[0,1],[r,n-2]),1),_N(-1)),c=$x([o,u],1),p=$x([s,l],1),h=Jx(sy(c,p),[i[0],i[1]]);t=KN(h)}if(t=kN(t),3===e.rank&&0!==e.shape[0]){var f=t,d=e.shape[0];t=Jx(t,[d,t.shape[0]/d,t.shape[1]]),f.dispose()}return t}});var YN=oy({split_:function(e,t,n){void 0===n&&(n=0);var r={x:ay(e,"x","split")},a={numOrSizeSplits:t,axis:n};return Jg.runKernel("SplitV",r,a)}});var JN=oy({rfft_:function(e,t){lv("float32"===e.dtype,(function(){return"The dtype for rfft() must be real value but got "+e.dtype}));var n,r=e.shape[e.shape.length-1],a=e.size/r;if(null!=t&&t<r){var i=e.shape.map((function(e){return 0})),o=e.shape.map((function(e){return e}));o[e.shape.length-1]=t,n=tw(e,i,o),r=t}else if(null!=t&&t>r){var s=e.shape.map((function(e){return e}));s[e.shape.length-1]=t-r,n=$x([e,qk(s)],e.shape.length-1),r=t}else n=e;var u=zw(n),l=Jx(sy(n,u),[a,r]),c=qN(l),p=Math.floor(r/2)+1,h=kN(c),f=Qw(c),d=YN(h,[p,r-p],h.shape.length-1),m=YN(f,[p,r-p],f.shape.length-1),v=n.shape.slice();return v[n.shape.length-1]=p,Jx(sy(d[0],m[0]),v)}});var ZN=oy({sqrt_:function(e){var t={x:ay(e,"x","sqrt")};return Jg.runKernel("Sqrt",t)}});var QN=oy({squaredDifference_:function(e,t){var n=ay(e,"a","squaredDifference"),r=ay(t,"b","squaredDifference"),a=Ug(n,r);n=a[0],r=a[1],Ow(n.shape,r.shape);var i={a:n,b:r};return Jg.runKernel("SquaredDifference",i,{})}});var $N=oy({squeeze_:function(e,t){var n=ay(e,"x","squeeze");return Jx(n,wv(n.shape,t).newShape)}});var eI=oy({stack_:function(e,t){void 0===t&&(t=0);var n=iy(e,"tensors","stack");lv(n.length>=1,(function(){return"Pass at least one tensor to tf.stack"})),n.length>0&&lv(t<=n[0].rank,(function(){return"Axis must be <= rank of the tensor"}));var r=n,a={axis:t};return Jg.runKernel("Pack",r,a)}});var tI=oy({step_:function(e,t){void 0===t&&(t=0);var n={x:ay(e,"x","step")},r={alpha:t};return Jg.runKernel("Step",n,r)}});var nI=oy({stridedSlice_:function(e,t,n,r,a,i,o,s,u){void 0===a&&(a=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===u&&(u=0);var l={x:ay(e,"x","stridedSlice")},c={begin:t,end:n,strides:r,beginMask:a,endMask:i,ellipsisMask:o,newAxisMask:s,shrinkAxisMask:u};return Jg.runKernel("StridedSlice",l,c)}});var rI=oy({tan_:function(e){var t={x:ay(e,"x","tan")};return Jg.runKernel(sg,t)}});function aI(e,t){pv(e);var n=ny(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return uy(e,null,n,t)}function iI(e,t,n){if(pv(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");var r=ny(e,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return uy(e,t,r,n)}var oI=oy({topk_:function(e,t,n){void 0===t&&(t=1),void 0===n&&(n=!0);var r=ay(e,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");var a=r.shape[r.shape.length-1];if(t>a)throw new Error("'k' passed to topk() must be <= the last dimension ("+a+") but got "+t);var i={x:r},o={k:t,sorted:n},s=Jg.runKernel("TopK",i,o);return{values:s[0],indices:s[1]}}});var sI=oy({truncatedNormal_:function(e,t,n,r,a){if(void 0===t&&(t=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");for(var i=new mN(t,n,r,!0,a),o=nb(e,r),s=0;s<o.values.length;s++)o.values[s]=i.nextValue();return o.toTensor()}});var uI=oy({unique_:function(e,t){void 0===t&&(t=0);var n=ay(e,"x","unique",null);lv(n.rank>0,(function(){return"The input tensor must be at least 1D"}));var r={x:n},a={axis:t},i=Jg.runKernel("Unique",r,a);return{values:i[0],indices:i[1]}}});var lI=oy({unsortedSegmentSum_:function(e,t,n){var r=ay(e,"x","unsortedSegmentSum"),a=ay(t,"segmentIds","unsortedSegmentSum","int32");lv(mv(n),(function(){return"numSegments must be of dtype int"}));var i={x:r,segmentIds:a},o={numSegments:n};return Jg.runKernel("UnsortedSegmentSum",i,o)}});var cI=oy({unstack_:function(e,t){void 0===t&&(t=0);var n=ay(e,"x","unstack");lv(t>=-n.shape.length&&t<n.shape.length,(function(){return"Axis = "+t+" is not in [-"+n.shape.length+", "+n.shape.length+")"}));var r={value:n},a={axis:t};return Jg.runKernel("Unpack",r,a)}});function pI(e,t,n,r){return void 0===t&&(t=!0),Jg.makeVariable(e,t,n,r)}function hI(e,t){for(var n=[],r=0;r<t.length;r++)t[r]&&n.push(r);for(var a=nb(e,"int32"),i=nb([n.length,e.length],"int32"),o=0;o<n.length;o++){var s=a.indexToLoc(n[o]),u=o*e.length;i.values.set(s,u)}return i.toTensor()}function fI(){return(fI=Gm(regeneratorRuntime.mark((function e(t){var n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=ay(t,"condition","whereAsync","bool"),e.next=3,n.data();case 3:return r=e.sent,a=hI(n.shape,r),t!==n&&n.dispose(),e.abrupt("return",a);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var dI=function(e){return fI.apply(this,arguments)};function mI(){return(mI=Gm(regeneratorRuntime.mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h,f,d,m,v;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(a=ay(t,"tensor","boolMask"),i=ay(n,"mask","boolMask","bool"),o=null==r?0:r,s=i.rank,u=a.shape,lv(s>0,(function(){return"mask cannot be scalar"})),cv(u.slice(o,o+s),i.shape,"mask's shape must match the first K dimensions of tensor's shape,"),l=1,c=o;c<o+s;c++)l*=u[c];return p=u.slice(0,o).concat([l],u.slice(o+s)),h=Jx(a,p),f=Jx(i,[-1]),e.next=14,dI(f);case 14:return d=e.sent,m=$N(d,[1]),v=Yw(h,m,o),t!==a&&a.dispose(),n!==i&&i.dispose(),m.dispose(),h.dispose(),f.dispose(),d.dispose(),e.abrupt("return",v);case 24:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var vI=function(e,t,n){return mI.apply(this,arguments)};var gI=oy({equalStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","equalStrict"),r=ay(t,"b","equalStrict");return cv(n.shape,r.shape,"Error in equalStrict: "),Mw(n,r)}}),yI=oy({greaterEqualStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","greaterEqualStrict"),r=ay(t,"b","greaterEqualStrict");return cv(n.shape,r.shape,"Error in greaterEqualStrict: "),Zw(n,r)}}),bI=oy({greaterStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","greaterStrict"),r=ay(t,"b","greaterStrict");return cv(n.shape,r.shape,"Error in greaterStrict: "),Jw(n,r)}}),xI=oy({lessEqualStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","lessEqualStrict"),r=ay(t,"b","lessEqualStrict");return cv(n.shape,r.shape,"Error in lessEqualStrict: "),ak(n,r)}}),wI=oy({lessStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","lessStrict"),r=ay(t,"b","lessStrict");return cv(n.shape,r.shape,"Error in lessStrict: "),rk(n,r)}}),kI=oy({notEqualStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","notEqualStrict"),r=ay(t,"b","notEqualStrict");return cv(n.shape,r.shape,"Error in notEqualStrict: "),Hk(n,r)}});var NI=oy({addStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","addStrict"),r=ay(t,"b","addStrict");return cv(n.shape,r.shape,"Error in addStrict: "),xx(n,r)}}),II=oy({divStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","div"),r=ay(t,"b","div");return cv(n.shape,r.shape,"Error in divideStrict: "),kx(n,r)}}),SI=oy({maximumStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","maximumStrict"),r=ay(t,"b","maximumStrict");return cv(n.shape,r.shape,"Error in maximumStrict: "),Mk(n,r)}}),TI=oy({minimumStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","minimumStrict"),r=ay(t,"b","minimumStrict");return cv(n.shape,r.shape,"Error in minimumStrict: "),Pk(n,r)}}),CI=oy({modStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","modStrict"),r=ay(t,"b","modStrict");return cv(n.shape,r.shape,"Error in modStrict: "),Wk(n,r)}}),EI=oy({mulStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","mul"),r=ay(t,"b","mul");return cv(n.shape,r.shape,"Error in multiplyStrict: "),Nx(n,r)}}),RI=oy({powStrict_:function(e,t){return px("strict variants of ops have been deprecated and will be removed in future"),cv(e.shape,t.shape,"Error in powStrict: "),rN(e,t)}}),AI=oy({squaredDifferenceStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","squaredDifferenceStrict"),r=ay(t,"b","squaredDifferenceStrict");return cv(n.shape,r.shape,"Error in squaredDifferenceStrict: "),QN(n,r)}}),DI=oy({subStrict_:function(e,t){px("strict variants of ops have been deprecated and will be removed in future");var n=ay(e,"a","subStrict"),r=ay(t,"b","subStrict");return cv(n.shape,r.shape,"Error in subStrict: "),vk(n,r)}});var FI=oy({norm_:function(e,t,n,r){void 0===t&&(t="euclidean"),void 0===n&&(n=null),void 0===r&&(r=!1);var a=function e(t,n,r){void 0===r&&(r=null);if(0===t.rank)return Ix(t);if(1!==t.rank&&null===r)return e(Jx(t,[-1]),n,r);if(1===t.rank||"number"==typeof r||Array.isArray(r)&&1===r.length){if(1===n)return gk(Ix(t),r);if(n===1/0)return mk(Ix(t),r);if(n===-1/0)return zk(Ix(t),r);if("euclidean"===n||2===n)return ZN(gk(rN(Ix(t),_N(2,"int32")),r));throw new Error("Error in norm: invalid ord value: "+n)}if(Array.isArray(r)&&2===r.length){if(1===n)return mk(gk(Ix(t),r[0]),r[1]-1);if(n===1/0)return mk(gk(Ix(t),r[1]),r[0]);if(n===-1/0)return zk(gk(Ix(t),r[1]),r[0]);if("fro"===n||"euclidean"===n)return ZN(gk(Vk(t),r));throw new Error("Error in norm: invalid ord value: "+n)}throw new Error("Error in norm: invalid axis: "+r)}(e=ay(e,"x","norm"),t,n),i=a.shape;if(r){var o=xv(n,e.shape);i=kk(a.shape,o)}return Jx(a,i)}});var _I=oy({movingAverage_:function(e,t,n,r,a){void 0===a&&(a=!0);var i=ay(e,"v","movingAverage"),o=ay(t,"x","movingAverage"),s=ay(n,"decay","movingAverage");Gg(i,o),lv(dv(i.shape,o.shape),(function(){return"Shape mismatch in v and x"}));var u=_N(1),l=vk(u,s),c=Nx(vk(o,i),l);if(a){lv(null!=r,(function(){return"When using zeroDebias: true, step is required."}));var p=ay(r,"step","movingAverage");c=kx(c,vk(u,rN(s,p)))}return xx(i,c)}});var OI=oy({scatterND_:function(e,t,n){var r=ay(e,"indices","scatterND","int32"),a=ay(t,"updates","scatterND");Lb(a,r,n);var i={indices:r,updates:a},o={shape:n};return Jg.runKernel("ScatterNd",i,o)}});var MI=oy({sparseToDense_:function(e,t,n,r){void 0===r&&(r=0);var a=ay(e,"sparseIndices","sparseToDense","int32"),i=ay(t,"sparseValues","sparseToDense"),o=ay(r,"defaultValue","sparseToDense",i.dtype);!function(e,t,n,r){if("int32"!==e.dtype)throw new Error("tf.sparseToDense() expects the indices to be int32 type, but the dtype was "+e.dtype+".");if(e.rank>2)throw new Error("sparseIndices should be a scalar, vector, or matrix, but got shape "+e.shape+".");var a=e.rank>0?e.shape[0]:1,i=e.rank>1?e.shape[1]:1;if(n.length!==i)throw new Error("outputShape has incorrect number of elements:, "+n.length+", should be: "+i+".");var o=t.size;if(0!==t.rank&&(1!==t.rank||o!==a))throw new Error("sparseValues has incorrect shape "+t.shape+", should be [] or ["+a+"]");if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(a,i,n,o);var s={sparseIndices:a,sparseValues:i,defaultValue:o},u={outputShape:n};return Jg.runKernel("SparseToDense",s,u)}});var LI=oy({gatherND_:function(e,t){var n=ay(t,"indices","gatherND","int32"),r={params:ay(e,"x","gatherND"),indices:n};return Jg.runKernel("GatherNd",r)}});var zI=oy({dropout_:function(e,t,n,r){var a=ay(e,"x","dropout");if(lv("float32"===a.dtype,(function(){return"x has to be a floating point tensor since it's going to be scaled, but got a "+a.dtype+" tensor instead."})),lv(t>=0&&t<1,(function(){return"rate must be a float in the range [0, 1), but got "+t+"."})),0===t)return e instanceof Fg?a.clone():a;var i=function(e,t){if(null==t)return e.shape.slice();if(dv(e.shape,t))return t;if(e.shape.length===t.length){for(var n=[],r=0;r<e.shape.length;r++)null==t[r]&&null!=e.shape[r]?n.push(e.shape[r]):n.push(t[r]);return n}return t}(a,n),o=1-t,s=kx(Xw(xx(xN(i,0,1,"float32",r),o)),o);return Nx(a,s)}});function PI(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function BI(e,t,n){for(var r=1-e%2,a=new Float32Array(e),i=0;i<e;++i){var o=2*Math.PI*i/(e+r-1);a[i]=t-n*Math.cos(o)}return aI(a,"float32")}function WI(){return(WI=Gm(regeneratorRuntime.mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h,f,d,m,v,g;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r=1),a=ay(t,"predictions","inTopK"),i=ay(n,"targets","inTopK"),lv(a.rank>1,(function(){return"inTopK() expects the predictions to be of rank 2 or higher, but got "+a.rank})),lv(a.rank-1===i.rank,(function(){return"predictions rank should be 1 larger than targets rank, but got predictions rank "+a.rank+" and targets rank "+i.rank})),cv(a.shape.slice(0,a.shape.length-1),i.shape,"predictions's shape should be align with the targets' shape, except the last dimension."),o=a.shape[a.shape.length-1],lv(r>0&&r<=o,(function(){return"'k' passed to inTopK() must be > 0 && <= the predictions last dimension ("+o+"), but got "+r})),e.next=10,a.data();case 10:return s=e.sent,e.next=13,i.data();case 13:u=e.sent,l=s.length/o,c=o,p=kv("bool",l),h=0;case 17:if(!(h<l)){e.next=35;break}for(f=h*c,d=s.subarray(f,f+c),m=[],v=0;v<d.length;v++)m.push({value:d[v],index:v});m.sort((function(e,t){return t.value-e.value})),p[h]=0,g=0;case 25:if(!(g<r)){e.next=32;break}if(m[g].index!==u[h]){e.next=29;break}return p[h]=1,e.abrupt("break",32);case 29:g++,e.next=25;break;case 32:h++,e.next=17;break;case 35:return t!==a&&a.dispose(),n!==i&&i.dispose(),e.abrupt("return",ly(p,i.shape,"bool"));case 38:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var VI=function(e,t,n){return WI.apply(this,arguments)};var UI=oy({conv2DBackpropFilter_:function(e,t,n,r,a,i,o){void 0===i&&(i="NHWC");var s=e;3===e.rank&&(s=Jx(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var u=t;3===u.rank&&(u=Jx(t,[1,t.shape[0],t.shape[1],t.shape[2]])),lv(4===s.rank,(function(){return"Error in conv2dDerFilter: input must be rank 4, but got shape "+s.shape+"."})),lv(4===u.rank,(function(){return"Error in conv2dDerFilter: dy must be rank 4, but got shape "+u.shape+"."})),lv(4===n.length,(function(){return"Error in conv2dDerFilter: filterShape must be length 4, but got "+n+"."}));var l="NHWC"===i?s.shape[3]:s.shape[1],c="NHWC"===i?u.shape[3]:u.shape[1];lv(l===n[2],(function(){return"Error in conv2dDerFilter: depth of input "+l+") must match input depth in filter ("+n[2]+"."})),lv(c===n[3],(function(){return"Error in conv2dDerFilter: depth of dy ("+c+") must match output depth for filter ("+n[3]+")."})),null!=o&&lv(mv(a),(function(){return"Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+a+"."}));var p={x:s,dy:u},h={strides:r,pad:a,dataFormat:i,dimRoundingMode:o,filterShape:n};return Jg.runKernel("Conv2DBackpropFilter",p,h)}});function GI(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return Nx(e,tI(t));throw new Error("Cannot compute gradient for fused activation "+n+".")}function jI(e,t){var n=t,r=_w(e.shape,t.shape);return r.length>0&&(n=gk(n,r)),Jx(n,e.shape)}function HI(e,t,n,r){if("linear"===t)return e;if("relu"===t)return IN(e);if("elu"===t)return Ww(e);if("relu6"===t)return SN(e);if("prelu"===t)return aN(e,n);if("leakyrelu"===t)return nk(e,r);throw new Error("Unknown fused activation "+t+".")}var qI=function(e,t){return!(e>0)||"linear"===t};var KI=oy({fusedConv2d_:function(e){var t=e.x,n=e.filter,r=e.strides,a=e.pad,i=e.dataFormat,o=void 0===i?"NHWC":i,s=e.dilations,u=void 0===s?[1,1]:s,l=e.dimRoundingMode,c=e.bias,p=e.activation,h=void 0===p?"linear":p,f=e.preluActivationWeights,d=e.leakyreluAlpha;if(h=h||"linear",!1===qI(Jg.state.gradientDepth,h)){var m=gw(t,n,r,a,o,u,l);return null!=c&&(m=xx(m,c)),HI(m,h,f,d)}var v=ay(t,"x","conv2d"),g=ay(n,"filter","conv2d"),y=v,b=!1;3===v.rank&&(b=!0,y=Jx(v,[1,v.shape[0],v.shape[1],v.shape[2]])),lv(4===y.rank,(function(){return"Error in fused conv2d: input must be rank 4, but got rank "+y.rank+"."})),lv(4===g.rank,(function(){return"Error in fused conv2d: filter must be rank 4, but got rank "+g.rank+"."})),null!=l&&lv(mv(a),(function(){return"Error in fused conv2d: pad must be an integer when using, dimRoundingMode "+l+" but got pad "+a+"."})),lv(y.shape[3]===g.shape[2],(function(){return"Error in conv2d: depth of input ("+y.shape[3]+") must match input depth for filter "+g.shape[2]+"."})),lv(Xx(r,u),(function(){return"Error in conv2D: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'"})),lv("NHWC"===o,(function(){return"Error in conv2d: got dataFormat of "+o+" but only NHWC is currently supported."}));var x,w,k=Wx(y.shape,g.shape,r,u,a,l);null!=c&&(x=Ug(x=ay(c,"bias","fused conv2d"),v)[0],Ow(k.outShape,x.shape)),null!=f&&(w=ay(f,"prelu weights","fused conv2d"));var N=function(e,t){var n=t[0],i=t[1],o=t[2],s=t[3],l=GI(e,o,h);lv(Kx(u),(function(){return"Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+u+"'"}));var c=[bw(i.shape,l,n,r,a),UI(i,l,n.shape,r,a)];if(null!=s){var p=jI(s,l);c.push(p)}return c},I={x:y,filter:g,bias:x,preluActivationWeights:w},S={strides:r,pad:a,dataFormat:o,dilations:u,dimRoundingMode:l,activation:h,leakyreluAlpha:d};return null==c?ck((function(e,t,n){var r=Jg.runKernel("FusedConv2D",I,S);return n([t,e,r]),b&&(r=Jx(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:N}}))(y,g):ck((function(e,t,n,r){var a=Jg.runKernel("FusedConv2D",I,S);return r([t,e,a,n]),b&&(a=Jx(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:N}}))(y,g,x)}});var XI=oy({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,r,a,i,o){void 0===i&&(i=[1,1]);var s=e;3===e.rank&&(s=Jx(e,[1,e.shape[0],e.shape[1],e.shape[2]]));var u=t;3===u.rank&&(u=Jx(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var l={x:s,dy:u},c={strides:r,pad:a,dimRoundingMode:o,dilations:i,filterShape:n};return Jg.runKernel("DepthwiseConv2dNativeBackpropFilter",l,c)}});var YI=oy({depthwiseConv2dNativeBackpropInput_:function(e,t,n,r,a,i,o){void 0===i&&(i=[1,1]);var s=t,u=!1;3===t.rank&&(u=!0,s=Jx(t,[1,t.shape[0],t.shape[1],t.shape[2]]));var l={dy:s,filter:n},c={strides:r,pad:a,dimRoundingMode:o,dilations:i,inputShape:e},p=Jg.runKernel("DepthwiseConv2dNativeBackpropInput",l,c);return u?Jx(p,[p.shape[1],p.shape[2],p.shape[3]]):p}});var JI=oy({fusedDepthwiseConv2d_:function(e){var t=e.x,n=e.filter,r=e.strides,a=e.pad,i=e.dataFormat,o=void 0===i?"NHWC":i,s=e.dilations,u=void 0===s?[1,1]:s,l=e.dimRoundingMode,c=e.bias,p=e.activation,h=void 0===p?"linear":p,f=e.preluActivationWeights,d=e.leakyreluAlpha;if(!1===qI(Jg.state.gradientDepth,h)){var m=Rw(t,n,r,a,o,u,l);return null!=c&&(m=xx(m,c)),HI(m,h,f,d)}var v=ay(t,"x","depthwiseConv2d"),g=ay(n,"filter","depthwiseConv2d"),y=v,b=!1;3===v.rank&&(b=!0,y=Jx(v,[1,v.shape[0],v.shape[1],v.shape[2]])),lv(4===y.rank,(function(){return"Error in fused depthwiseConv2d: input must be rank 4, but got rank "+y.rank+"."})),lv(4===g.rank,(function(){return"Error in fused depthwiseConv2d: filter must be rank 4, but got rank "+g.rank+"."})),lv(y.shape[3]===g.shape[2],(function(){return"Error in fused depthwiseConv2d: number of input channels ("+y.shape[3]+") must match the inChannels dimension in filter "+g.shape[2]+"."})),null==u&&(u=[1,1]),lv(Xx(r,u),(function(){return"Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'"})),null!=l&&lv(mv(a),(function(){return"Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode "+l+" but got pad "+a+"."}));var x,w,k=Wx(y.shape,g.shape,r,u,a,l,!0);if(null!=c){var N=Ug(x=ay(c,"bias","fused conv2d"),v);x=N[0],Ow(k.outShape,x.shape)}null!=f&&(w=ay(f,"prelu weights","fused depthwiseConv2d"));var I=function(e,t){lv(Kx(u),(function(){return"Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '"+u+"'"}));var n=t[0],i=t[1],o=t[2],s=t[3],c=GI(e,o,h),p=YI(i.shape,c,n,r,a,u,l),f=XI(i,c,n.shape,r,a,u,l);return null!=s?[p,f,jI(x,c)]:[p,f]},S={x:y,filter:g,bias:x,preluActivationWeights:w},T={strides:r,pad:a,dataFormat:o,dilations:u,dimRoundingMode:l,activation:h,leakyreluAlpha:d};return null==c?ck((function(e,t,n){var r=Jg.runKernel("FusedDepthwiseConv2D",S,T);return n([t,e,r]),b&&(r=Jx(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:I}}))(y,g):ck((function(e,t,n,r){var a=Jg.runKernel("FusedDepthwiseConv2D",S,T);return r([t,e,a,n]),b&&(a=Jx(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:I}}))(y,g,x)}});var ZI=oy({fusedMatMul_:function(e){var t=e.a,n=e.b,r=e.transposeA,a=void 0!==r&&r,i=e.transposeB,o=void 0!==i&&i,s=e.bias,u=e.activation,l=void 0===u?"linear":u,c=e.preluActivationWeights,p=e.leakyreluAlpha;if(!1===qI(Jg.state.gradientDepth,l)){var h=Ib(t,n,a,o);return null!=s&&(h=xx(h,s)),HI(h,l,c,p)}var f=ay(t,"a","fused matMul"),d=ay(n,"b","fused matMul"),m=Ug(f,d);f=m[0],d=m[1];var v=a?f.shape[f.rank-2]:f.shape[f.rank-1],g=o?d.shape[d.rank-1]:d.shape[d.rank-2],y=a?f.shape[f.rank-1]:f.shape[f.rank-2],b=o?d.shape[d.rank-2]:d.shape[d.rank-1],x=f.shape.slice(0,-2),w=d.shape.slice(0,-2),k=fv(x),N=fv(w);lv(f.rank>=2&&d.rank>=2&&f.rank===d.rank,(function(){return"Error in fused matMul: inputs must have the same rank of at least 2, got ranks "+f.rank+" and "+d.rank+"."})),lv(dv(x,w),(function(){return"Error in fused matMul: outer dimensions ("+x+") and ("+w+") of Tensors with shapes "+f.shape+" and "+d.shape+" must match."})),lv(v===g,(function(){return"Error in fused matMul: inner shapes ("+v+") and ("+g+") of Tensors with shapes "+f.shape+" and "+d.shape+" and transposeA="+a+" and transposeB="+o+" must match."}));var I,S,T=f.shape.slice(0,-2).concat([y,b]),C=Jx(f,a?[k,v,y]:[k,y,v]),E=Jx(d,o?[N,b,g]:[N,g,b]);null!=s&&(I=Ug(I=ay(s,"bias","fused matMul"),f)[0],Ow(T,I.shape)),null!=c&&(S=ay(c,"prelu weights","fused matMul"));var R=function(e,t){var n,r,i=t[0],u=t[1],c=t[2],p=t[3],h=GI(Jx(e,c.shape),c,l);return a||o?!a&&o?(n=Ib(h,u,!1,!1),r=Ib(h,i,!0,!1)):a&&!o?(n=Ib(u,h,!1,!0),r=Ib(i,h,!1,!1)):(n=Ib(u,h,!0,!0),r=Ib(h,i,!0,!0)):(n=Ib(h,u,!1,!0),r=Ib(i,h,!0,!1)),null!=s?[n,r,jI(p,h)]:[n,r]},A={a:C,b:E,bias:I,preluActivationWeights:S},D={transposeA:a,transposeB:o,activation:l,leakyreluAlpha:p};return null==s?ck((function(e,t,n){var r=Jg.runKernel("_FusedMatMul",A,D);return n([e,t,r]),{value:Jx(r,T),gradFunc:R}}))(C,E):ck((function(e,t,n,r){var a=Jg.runKernel("_FusedMatMul",A,D);return r([e,t,a,n]),{value:Jx(a,T),gradFunc:R}}))(C,E,I)}}),QI={__proto__:null,conv2d:KI,depthwiseConv2d:JI,matMul:ZI};var $I=oy({hammingWindow_:function(e){return BI(e,.54,.46)}});var eS=oy({hannWindow_:function(e){return BI(e,.5,.5)}});var tS=oy({frame_:function(e,t,n,r,a){void 0===r&&(r=!1),void 0===a&&(a=0);for(var i=0,o=[];i+t<=e.size;)o.push(tw(e,i,t)),i+=n;if(r)for(;i<e.size;){var s=i+t-e.size,u=$x([tw(e,i,t-s),Kw([s],a)]);o.push(u),i+=n}return 0===o.length?iI([],[0,t]):Jx($x(o),[o.length,t])}});var nS=oy({stft_:function(e,t,n,r,a){void 0===a&&(a=eS),null==r&&(r=PI(t));for(var i=tS(e,t,n),o=Nx(i,a(t)),s=[],u=0;u<i.shape[0];u++)s.push(JN(tw(o,[u,0],[1,t]),r));return $x(s)}});var rS=oy({cropAndResize_:function(e,t,n,r,a,i){void 0===a&&(a="bilinear"),void 0===i&&(i=0);var o=ay(e,"image","cropAndResize"),s=ay(t,"boxes","cropAndResize","float32"),u=ay(n,"boxInd","cropAndResize","int32"),l=s.shape[0];lv(4===o.rank,(function(){return"Error in cropAndResize: image must be rank 4,but got rank "+o.rank+"."})),lv(2===s.rank&&4===s.shape[1],(function(){return"Error in cropAndResize: boxes must be have size ["+l+",4] but had shape "+s.shape+"."})),lv(1===u.rank&&u.shape[0]===l,(function(){return"Error in cropAndResize: boxInd must be have size ["+l+"] but had shape "+s.shape+"."})),lv(2===r.length,(function(){return"Error in cropAndResize: cropSize must be of length 2, but got length "+r.length+"."})),lv(r[0]>=1&&r[1]>=1,(function(){return"cropSize must be atleast [1,1], but was "+r})),lv("bilinear"===a||"nearest"===a,(function(){return"method must be bilinear or nearest, but was "+a}));var c={image:o,boxes:s,boxInd:u},p={method:a,extrapolationValue:i,cropSize:r};return Jg.runKernel("CropAndResize",c,p)}});var aS=oy({flipLeftRight_:function(e){var t=ay(e,"image","flipLeftRight","float32");lv(4===t.rank,(function(){return"Error in flipLeftRight: image must be rank 4,but got rank "+t.rank+"."}));var n={image:t};return Jg.runKernel("FlipLeftRight",n,{})}});var iS=oy({rotateWithOffset_:function(e,t,n,r){void 0===n&&(n=0),void 0===r&&(r=.5);var a=ay(e,"image","rotateWithOffset","float32");lv(4===a.rank,(function(){return"Error in rotateWithOffset: image must be rank 4,but got rank "+a.rank+"."}));var i={image:a},o={radians:t,fillValue:n,center:r};return Jg.runKernel("RotateWithOffset",i,o)}});function oS(e,t,n,r,a,i){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==i&&(i=0);var o=e.shape[0];return n=Math.min(n,o),lv(0<=r&&r<=1,(function(){return"iouThreshold must be in [0, 1], but was '"+r+"'"})),lv(2===e.rank,(function(){return"boxes must be a 2D tensor, but was of rank '"+e.rank+"'"})),lv(4===e.shape[1],(function(){return"boxes must have 4 columns, but 2nd dimension was "+e.shape[1]})),lv(1===t.rank,(function(){return"scores must be a 1D tensor"})),lv(t.shape[0]===o,(function(){return"scores has incompatible shape with boxes. Expected "+o+", but was "+t.shape[0]})),lv(0<=i&&i<=1,(function(){return"softNmsSigma must be in [0, 1], but was '"+i+"'"})),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:i}}var sS=oy({nonMaxSuppression_:function(e,t,n,r,a){void 0===r&&(r=.5),void 0===a&&(a=Number.NEGATIVE_INFINITY);var i=ay(e,"boxes","nonMaxSuppression"),o=ay(t,"scores","nonMaxSuppression"),s=oS(i,o,n,r,a),u={maxOutputSize:n=s.maxOutputSize,iouThreshold:r=s.iouThreshold,scoreThreshold:a=s.scoreThreshold};return Jg.runKernel("NonMaxSuppressionV3",{boxes:i,scores:o},u)}});function uS(e,t,n){var r=function(e,t,n){return function(e,t,n){var r=0,a=e.length,i=0,o=!1;for(;r<a;){var s=n(t,e[i=r+(a-r>>>1)]);s>0?r=i+1:(a=i,o=!s)}return o?r:-r-1}(e,t,n||lS)}(e,t,n),a=r<0?-(r+1):r;e.splice(a,0,t)}function lS(e,t){return e>t?1:e<t?-1:0}function cS(e,t,n,r,a){return fS(e,t,n,r,a,0)}function pS(e,t,n,r,a,i){return fS(e,t,n,r,a,0,!1,i,!0)}function hS(e,t,n,r,a,i){return fS(e,t,n,r,a,i,!0)}function fS(e,t,n,r,a,i,o,s,u){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===u&&(u=!1);for(var l=[],c=0;c<t.length;c++)t[c]>a&&l.push({score:t[c],boxIndex:c,suppressBeginIndex:0});l.sort(vS);for(var p=i>0?-.5/i:0,h=[],f=[];h.length<n&&l.length>0;){var d=l.pop(),m=d.score,v=d.boxIndex,g=d.suppressBeginIndex;if(m<a)break;for(var y=!1,b=h.length-1;b>=g;--b){var x=dS(e,v,h[b]);if(x>=r){y=!0;break}if(d.score=d.score*mS(r,p,x),d.score<=a)break}d.suppressBeginIndex=h.length,y||(d.score===m?(h.push(v),f.push(d.score)):d.score>a&&uS(l,d,vS))}var w=h.length,k=n-w;s&&k>0&&(h.push.apply(h,new Array(k).fill(0)),f.push.apply(f,new Array(k).fill(0)));var N={selectedIndices:h};return o&&(N.selectedScores=f),u&&(N.validOutputs=w),N}function dS(e,t,n){var r=e.subarray(4*t,4*t+4),a=e.subarray(4*n,4*n+4),i=Math.min(r[0],r[2]),o=Math.min(r[1],r[3]),s=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),l=Math.min(a[0],a[2]),c=Math.min(a[1],a[3]),p=Math.max(a[0],a[2]),h=Math.max(a[1],a[3]),f=(s-i)*(u-o),d=(p-l)*(h-c);if(f<=0||d<=0)return 0;var m=Math.max(i,l),v=Math.max(o,c),g=Math.min(s,p),y=Math.min(u,h),b=Math.max(g-m,0)*Math.max(y-v,0);return b/(f+d-b)}function mS(e,t,n){var r=Math.exp(t*n*n);return n<=e?r:0}function vS(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}function gS(){return(gS=Gm(regeneratorRuntime.mark((function e(t,n,r,a,i){var o,s,u,l,c,p,h,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===a&&(a=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),o=ay(t,"boxes","nonMaxSuppressionAsync"),s=ay(n,"scores","nonMaxSuppressionAsync"),u=oS(o,s,r,a,i),r=u.maxOutputSize,a=u.iouThreshold,i=u.scoreThreshold,e.next=10,Promise.all([o.data(),s.data()]);case 10:return l=e.sent,c=l[0],p=l[1],h=cS(c,p,r,a,i),f=h.selectedIndices,o!==t&&o.dispose(),s!==n&&s.dispose(),e.abrupt("return",aI(f,"int32"));case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var yS=function(e,t,n,r,a){return gS.apply(this,arguments)};var bS=oy({nonMaxSuppressionWithScore_:function(e,t,n,r,a,i){void 0===r&&(r=.5),void 0===a&&(a=Number.NEGATIVE_INFINITY),void 0===i&&(i=0);var o=ay(e,"boxes","nonMaxSuppression"),s=ay(t,"scores","nonMaxSuppression"),u=oS(o,s,n,r,a,i),l={boxes:o,scores:s},c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:a=u.scoreThreshold,softNmsSigma:i=u.softNmsSigma},p=Jg.runKernel("NonMaxSuppressionV5",l,c);return{selectedIndices:p[0],selectedScores:p[1]}}});function xS(){return(xS=Gm(regeneratorRuntime.mark((function e(t,n,r,a,i,o){var s,u,l,c,p,h,f,d,m;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===a&&(a=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),void 0===o&&(o=0),s=ay(t,"boxes","nonMaxSuppressionAsync"),u=ay(n,"scores","nonMaxSuppressionAsync"),l=oS(s,u,r,a,i,o),r=l.maxOutputSize,a=l.iouThreshold,i=l.scoreThreshold,o=l.softNmsSigma,e.next=12,Promise.all([s.data(),u.data()]);case 12:return c=e.sent,p=c[0],h=c[1],f=hS(p,h,r,a,i,o),d=f.selectedIndices,m=f.selectedScores,s!==t&&s.dispose(),u!==n&&u.dispose(),e.abrupt("return",{selectedIndices:aI(d,"int32"),selectedScores:aI(m)});case 19:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var wS=function(e,t,n,r,a,i){return xS.apply(this,arguments)};var kS=oy({nonMaxSuppressionPadded_:function(e,t,n,r,a,i){void 0===r&&(r=.5),void 0===a&&(a=Number.NEGATIVE_INFINITY),void 0===i&&(i=!1);var o=ay(e,"boxes","nonMaxSuppression"),s=ay(t,"scores","nonMaxSuppression"),u=oS(o,s,n,r,a,null),l={boxes:o,scores:s},c={maxOutputSize:u.maxOutputSize,iouThreshold:u.iouThreshold,scoreThreshold:u.scoreThreshold,padToMaxOutputSize:i},p=Jg.runKernel("NonMaxSuppressionV4",l,c);return{selectedIndices:p[0],validOutputs:p[1]}}});function NS(){return(NS=Gm(regeneratorRuntime.mark((function e(t,n,r,a,i,o){var s,u,l,c,p,h,f,d,m,v,g,y;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===a&&(a=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),void 0===o&&(o=!1),s=ay(t,"boxes","nonMaxSuppressionAsync"),u=ay(n,"scores","nonMaxSuppressionAsync"),l=oS(s,u,r,a,i,null),c=l.maxOutputSize,p=l.iouThreshold,h=l.scoreThreshold,e.next=11,Promise.all([s.data(),u.data()]);case 11:return f=e.sent,d=f[0],m=f[1],v=pS(d,m,c,p,h,o),g=v.selectedIndices,y=v.validOutputs,s!==t&&s.dispose(),u!==n&&u.dispose(),e.abrupt("return",{selectedIndices:aI(g,"int32"),validOutputs:_N(y,"int32")});case 18:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var IS=function(e,t,n,r,a,i){return NS.apply(this,arguments)};var SS=oy({resizeBilinear_:function(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var a=ay(e,"images","resizeBilinear");lv(3===a.rank||4===a.rank,(function(){return"Error in resizeBilinear: x must be rank 3 or 4, but got rank "+a.rank+"."})),lv(2===t.length,(function(){return"Error in resizeBilinear: new shape must 2D, but got shape "+t+"."})),lv(!1===r||!1===n,(function(){return"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."}));var i=a,o=!1;3===a.rank&&(o=!0,i=Jx(a,[1,a.shape[0],a.shape[1],a.shape[2]]));var s={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=Jg.runKernel("ResizeBilinear",s,u);return o?Jx(l,[l.shape[1],l.shape[2],l.shape[3]]):l}});var TS=oy({resizeNearestNeighbor_:function(e,t,n,r){void 0===n&&(n=!1),void 0===r&&(r=!1);var a=ay(e,"images","resizeNearestNeighbor");lv(3===a.rank||4===a.rank,(function(){return"Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank "+a.rank+"."})),lv(2===t.length,(function(){return"Error in resizeNearestNeighbor: new shape must 2D, but got shape "+t+"."})),lv("float32"===a.dtype||"int32"===a.dtype,(function(){return"`images` must have `int32` or `float32` as dtype"})),lv(!1===r||!1===n,(function(){return"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."}));var i=a,o=!1;3===a.rank&&(o=!0,i=Jx(a,[1,a.shape[0],a.shape[1],a.shape[2]]));var s={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=Jg.runKernel("ResizeNearestNeighbor",s,u);return o?Jx(l,[l.shape[1],l.shape[2],l.shape[3]]):l}});var CS=oy({bandPart_:function(e,t,n){lv(t%1==0,(function(){return"bandPart(): numLower must be an integer, got "+t+"."})),lv(n%1==0,(function(){return"bandPart(): numUpper must be an integer, got "+n+"."}));var r=ay(e,"a","bandPart");lv(r.rank>=2,(function(){return"bandPart(): Rank must be at least 2, got "+r.rank+"."}));var a=r.shape,i=r.shape.slice(-2),o=i[0],s=i[1];if(!(t<=o))throw new Error("bandPart(): numLower ("+t+") must not be greater than the number of rows ("+o+").");if(!(n<=s))throw new Error("bandPart(): numUpper ("+n+") must not be greater than the number of columns ("+s+").");t<0&&(t=o),n<0&&(n=s);var u=Jx(wN(0,o,1,"int32"),[-1,1]),l=wN(0,s,1,"int32"),c=vk(u,l),p=Ek(ak(c,_N(+t,"int32")),Zw(c,_N(-n,"int32"))),h=qk([o,s],r.dtype);return Jx(eI(cI(Jx(r,[-1,o,s])).map((function(e){return Lw(p,e,h)}))),a)}});var ES=oy({gramSchmidt_:function(e){var t;Array.isArray(e)?function(){t=!1,lv(null!=e&&e.length>0,(function(){return"Gram-Schmidt process: input must not be null, undefined, or empty"}));for(var n=e[0].shape[0],r=function(t){lv(e[t].shape[0]===n,(function(){return"Gram-Schmidt: Non-unique lengths found in the input vectors: ("+e[t].shape[0]+" vs. "+n+")"}))},a=1;a<e.length;++a)r(a)}():(t=!0,e=YN(e,e.shape[0],0).map((function(e){return $N(e,[0])}))),lv(e.length<=e[0].shape[0],(function(){return"Gram-Schmidt: Number of vectors ("+e.length+") exceeds number of dimensions ("+e[0].shape[0]+")."}));for(var n=[],r=e,a=function(e){n.push(Jg.tidy((function(){var t=r[e];if(e>0)for(var a=0;a<e;++a){var i=Nx(gk(Nx(n[a],t)),n[a]);t=vk(t,i)}return kx(t,FI(t,"euclidean"))})))},i=0;i<e.length;++i)a(i);return t?eI(n,0):n}});function RS(e,t){return void 0===t&&(t=!1),Jg.tidy((function(){lv(2===e.shape.length,(function(){return"qr2d() requires a 2D Tensor, but got a "+e.shape.length+"D Tensor."}));for(var n=e.shape[0],r=e.shape[1],a=qw(n),i=ab(e),o=iI([[1]],[1,1]),s=ab(o),u=n>=r?r:n,l=function(e){var t=i,u=s,l=a,c=Jg.tidy((function(){var t=tw(i,[e,e],[n-e,1]),u=FI(t),l=tw(i,[e,e],[1,1]),c=Lw(Jw(l,0),iI([[-1]]),iI([[1]])),p=vk(l,Nx(c,u)),h=kx(t,p);s=1===h.shape[0]?ab(o):$x([o,tw(h,[1,0],[h.shape[0]-1,h.shape[1]])],0);var f=hk(kx(Ib(c,p),u)),d=tw(i,[e,0],[n-e,r]),m=Nx(f,s),v=Tb(s);if(0===e)i=vk(d,Ib(m,Ib(v,d)));else{var g=vk(d,Ib(m,Ib(v,d)));i=$x([tw(i,[0,0],[e,r]),g],0)}var y=Tb(m),b=tw(a,[0,e],[n,a.shape[1]-e]);if(0===e)a=vk(b,Ib(Ib(b,s),y));else{var x=vk(b,Ib(Ib(b,s),y));a=$x([tw(a,[0,0],[n,e]),x],1)}return[s,i,a]}));s=c[0],i=c[1],a=c[2],mx([t,u,l])},c=0;c<u;++c)l(c);return!t&&n>r&&(a=tw(a,[0,0],[n,r]),i=tw(i,[0,0],[r,r])),[a,i]}))}var AS,DS=oy({qr_:function(e,t){if(void 0===t&&(t=!1),lv(e.rank>=2,(function(){return"qr() requires input tensor to have a rank >= 2, but got rank "+e.rank})),2===e.rank)return RS(e,t);var n=e.shape.slice(0,e.shape.length-2).reduce((function(e,t){return e*t})),r=cI(Jx(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],i=[];return r.forEach((function(e){var n=RS(e,t),r=n[0],o=n[1];a.push(r),i.push(o)})),[Jx(eI(a,0),e.shape),Jx(eI(i,0),e.shape)]}});(AS=e.Reduction||(e.Reduction={}))[AS.NONE=0]="NONE",AS[AS.MEAN=1]="MEAN",AS[AS.SUM=2]="SUM",AS[AS.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS";var FS=oy({computeWeightedLoss_:function(t,n,r){void 0===r&&(r=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var a=ay(t,"losses","computeWeightedLoss"),i=null;null!=n&&(i=ay(n,"weights","computeWeightedLoss"));var o=null==i?a:Nx(a,i);if(r===e.Reduction.NONE)return o;if(r===e.Reduction.SUM)return gk(o);if(r===e.Reduction.MEAN){if(null==i)return Lk(o);var s=a.size/i.size,u=kx(gk(o),gk(i));return s>1?kx(u,_N(s)):u}if(r===e.Reduction.SUM_BY_NONZERO_WEIGHTS){if(null==i)return kx(gk(o),_N(a.size));var l=Nx(i,Kk(a.shape)),c=rb(gk(Hk(l,_N(0))),"float32");return kx(gk(o),c)}throw Error("Unknown reduction: "+r)}});var _S=oy({absoluteDifference_:function(t,n,r,a){void 0===a&&(a=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=ay(t,"labels","absoluteDifference"),o=ay(n,"predictions","absoluteDifference"),s=null;null!=r&&(s=ay(r,"weights","absoluteDifference")),cv(i.shape,o.shape,"Error in absoluteDifference: ");var u=Ix(vk(i,o));return FS(u,s,a)}});var OS=oy({cosineDistance_:function(t,n,r,a,i){void 0===i&&(i=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=ay(t,"labels","cosineDistance"),s=ay(n,"predictions","cosineDistance"),u=null;null!=a&&(u=ay(a,"weights","cosineDistance")),cv(o.shape,s.shape,"Error in cosineDistance: ");var l=_N(1),c=vk(l,gk(Nx(o,s),r,!0));return FS(c,u,i)}});var MS=oy({hingeLoss_:function(t,n,r,a){void 0===a&&(a=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=ay(t,"labels","hingeLoss"),o=ay(n,"predictions","hingeLoss"),s=null;null!=r&&(s=ay(r,"weights","hingeLoss")),cv(i.shape,o.shape,"Error in hingeLoss: ");var u=_N(1);i=vk(Nx(_N(2),i),u);var l=IN(vk(u,Nx(i,o)));return FS(l,s,a)}});var LS=oy({huberLoss_:function(t,n,r,a,i){void 0===a&&(a=1),void 0===i&&(i=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=ay(t,"labels","huberLoss"),s=ay(n,"predictions","huberLoss"),u=null;null!=r&&(u=ay(r,"weights","huberLoss")),cv(o.shape,s.shape,"Error in huberLoss: ");var l=_N(a),c=Ix(vk(s,o)),p=Pk(c,l),h=vk(c,p),f=xx(Nx(_N(.5),Vk(p)),Nx(l,h));return FS(f,u,i)}});var zS=oy({logLoss_:function(t,n,r,a,i){void 0===a&&(a=1e-7),void 0===i&&(i=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=ay(t,"labels","logLoss"),s=ay(n,"predictions","logLoss"),u=null;null!=r&&(u=ay(r,"weights","logLoss")),cv(o.shape,s.shape,"Error in logLoss: ");var l=_N(1),c=_N(a),p=hk(Nx(o,sk(xx(s,c)))),h=Nx(vk(l,o),sk(xx(vk(l,s),c))),f=vk(p,h);return FS(f,u,i)}});var PS=oy({meanSquaredError_:function(t,n,r,a){void 0===a&&(a=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var i=ay(t,"labels","meanSquaredError"),o=ay(n,"predictions","meanSquaredError"),s=null;null!=r&&(s=ay(r,"weights","meanSquaredError")),cv(i.shape,o.shape,"Error in meanSquaredError: ");var u=QN(i,o);return FS(u,s,a)}});var BS=oy({sigmoidCrossEntropy_:function(t,n,r,a,i){void 0===a&&(a=0),void 0===i&&(i=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=ay(t,"multiClassLabels","sigmoidCrossEntropy"),s=ay(n,"logits","sigmoidCrossEntropy"),u=null;if(null!=r&&(u=ay(r,"weights","sigmoidCrossEntropy")),cv(o.shape,s.shape,"Error in sigmoidCrossEntropy: "),a>0){var l=_N(a),c=_N(1),p=_N(.5);o=xx(Nx(o,vk(c,l)),Nx(p,l))}var h=function(e,t){var n=ay(e,"labels","sigmoidCrossEntropyWithLogits"),r=ay(t,"logits","sigmoidCrossEntropyWithLogits");cv(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");var a=IN(r),i=Nx(r,n),o=uk(Uw(hk(Ix(r))));return xx(vk(a,i),o)}(o,s);return FS(h,u,i)}});var WS=oy({softmaxCrossEntropy_:function(t,n,r,a,i){void 0===a&&(a=0),void 0===i&&(i=e.Reduction.SUM_BY_NONZERO_WEIGHTS);var o=ay(t,"onehotLabels","softmaxCrossEntropy"),s=ay(n,"logits","softmaxCrossEntropy"),u=null;if(null!=r&&(u=ay(r,"weights","softmaxCrossEntropy")),cv(o.shape,s.shape,"Error in softmaxCrossEntropy: "),a>0){var l=_N(a),c=_N(1),p=_N(o.shape[1]);o=xx(Nx(o,vk(c,l)),kx(l,p))}var h=function(e,t,n){if(void 0===n&&(n=-1),-1===n&&(n=t.rank-1),n!==t.rank-1)throw Error("Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank "+t.rank+" and dim was "+n);return ck((function(e,t,r){var a=Ck(t,[n],!0),i=vk(rb(t,"float32"),a);r([e,i]);var o=hk(Nx(i,e));return{value:gk(o,[n]),gradFunc:function(e,t){var r=t[0],a=t[1],i=kk(e.shape,[n]);return[Nx(Jx(e,i),vk(rb(r,"float32"),Uw(a))),Nx(Jx(e,i),vk(Uw(a),rb(r,"float32")))]}}}))(e,t)}(o,s);return FS(h,u,i)}}),VS={fft:qN,ifft:KN,rfft:JN,irfft:XN},US={hammingWindow:$I,hannWindow:eS,frame:tS,stft:nS},GS={flipLeftRight:aS,resizeNearestNeighbor:TS,resizeBilinear:SS,rotateWithOffset:iS,cropAndResize:rS,nonMaxSuppression:sS,nonMaxSuppressionAsync:yS,nonMaxSuppressionWithScore:bS,nonMaxSuppressionWithScoreAsync:wS,nonMaxSuppressionPadded:kS,nonMaxSuppressionPaddedAsync:IS},jS={bandPart:CS,gramSchmidt:ES,qr:DS},HS={absoluteDifference:_S,computeWeightedLoss:FS,cosineDistance:OS,hingeLoss:MS,huberLoss:LS,logLoss:zS,meanSquaredError:PS,sigmoidCrossEntropy:BS,softmaxCrossEntropy:WS},qS=function(e){function t(){return e.apply(this,arguments)||this}qm(t,e);var n=t.prototype;return n.minimize=function(e,t,n){void 0===t&&(t=!1);var r=this.computeGradients(e,n),a=r.value,i=r.grads;if(null!=n){var o=n.map((function(e){return{name:e.name,tensor:i[e.name]}}));this.applyGradients(o)}else this.applyGradients(i);return mx(i),t?a:(a.dispose(),null)},n.incrementIterations=function(){this.iterations_=this.iterations+1},n.computeGradients=function(e,t){return lk(e,t)},n.dispose=function(){null!=this.iterations_&&mx(this.iterations_)},n.saveIterations=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null==this.iterations_&&(this.iterations_=0),e.abrupt("return",{name:"iter",tensor:_N(this.iterations_,"int32")});case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.getWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("getWeights() is not implemented for this optimizer yet.");case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("setWeights() is not implemented for this optimizer class "+this.getClassName());case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.extractIterations=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t[0].tensor.data();case 2:return this.iterations_=e.sent[0],e.abrupt("return",t.slice(1));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),Hm(t,[{key:"iterations",get:function(){return null==this.iterations_&&(this.iterations_=0),this.iterations_}}]),t}(nx);Object.defineProperty(qS,Symbol.hasInstance,{value:function(e){return null!=e.minimize&&null!=e.computeGradients&&null!=e.applyGradients}});var KS=function(e){function t(t,n,r){var a;return void 0===r&&(r=null),(a=e.call(this)||this).learningRate=t,a.rho=n,a.epsilon=r,a.accumulatedGrads=[],a.accumulatedUpdates=[],null==r&&(a.epsilon=Jg.backend.epsilon()),a}qm(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=Jg.registeredVariables[n];null==t.accumulatedGrads[r]&&(t.accumulatedGrads[r]={originalName:n+"/accum_grad",variable:dx((function(){return zw(a).variable(!1)}))}),null==t.accumulatedUpdates[r]&&(t.accumulatedUpdates[r]={originalName:n+"/accum_var",variable:dx((function(){return zw(a).variable(!1)}))});var i=Array.isArray(e)?e[r].tensor:e[n];if(null!=i){var o=t.accumulatedGrads[r].variable,s=t.accumulatedUpdates[r].variable;dx((function(){var e=xx(Nx(o,t.rho),Nx(Vk(i),1-t.rho)),n=Nx(kx(ZN(xx(s,t.epsilon)),ZN(xx(o,t.epsilon))),i),r=xx(Nx(s,t.rho),Nx(Vk(n),1-t.rho));o.assign(e),s.assign(r);var u=xx(Nx(n,-t.learningRate),a);a.assign(u)}))}})),this.incrementIterations()},n.dispose=function(){null!=this.accumulatedUpdates&&(mx(this.accumulatedGrads.map((function(e){return e.variable}))),mx(this.accumulatedUpdates.map((function(e){return e.variable}))))},n.getWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(this.accumulatedGrads,this.accumulatedUpdates),e.next=3,this.saveIterations();case 3:return e.t0=e.sent,e.abrupt("return",[e.t0].concat(t.map((function(e){return{name:e.originalName,tensor:e.variable}}))));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:t=e.sent,n=t.length/2,!1,this.accumulatedGrads=t.slice(0,n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),this.accumulatedUpdates=t.slice(n,2*n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}}));case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon}},t.fromConfig=function(e,t){return new e(t.learningRate,t.rho,t.epsilon)},t}(qS);KS.className="Adadelta",ax(KS);var XS=function(e){function t(t,n){var r;return void 0===n&&(n=.1),(r=e.call(this)||this).learningRate=t,r.initialAccumulatorValue=n,r.accumulatedGrads=[],r}qm(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=Jg.registeredVariables[n];if(null==t.accumulatedGrads[r]){t.accumulatedGrads[r]={originalName:n+"/accumulator",variable:dx((function(){return Kw(a.shape,t.initialAccumulatorValue).variable(!1)}))}}var i=Array.isArray(e)?e[r].tensor:e[n];if(null!=i){var o=t.accumulatedGrads[r].variable;dx((function(){var e=xx(o,Vk(i));o.assign(e);var n=xx(Nx(kx(i,ZN(xx(e,Jg.backend.epsilon()))),-t.learningRate),a);a.assign(n)}))}})),this.incrementIterations()},n.dispose=function(){null!=this.accumulatedGrads&&mx(this.accumulatedGrads.map((function(e){return e.variable})))},n.getWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.saveIterations();case 2:return e.t0=e.sent,e.abrupt("return",[e.t0].concat(this.accumulatedGrads.map((function(e){return{name:e.originalName,tensor:e.variable}}))));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:t=e.sent,!1,this.accumulatedGrads=t.map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}}));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue}},t.fromConfig=function(e,t){return new e(t.learningRate,t.initialAccumulatorValue)},t}(qS);XS.className="Adagrad",ax(XS);var YS=function(e){function t(t,n,r,a){var i;return void 0===a&&(a=null),(i=e.call(this)||this).learningRate=t,i.beta1=n,i.beta2=r,i.epsilon=a,i.accumulatedFirstMoment=[],i.accumulatedSecondMoment=[],dx((function(){i.accBeta1=_N(n).variable(),i.accBeta2=_N(r).variable()})),null==a&&(i.epsilon=Jg.backend.epsilon()),i}qm(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this,n=Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e);dx((function(){var r=vk(1,t.accBeta1),a=vk(1,t.accBeta2);n.forEach((function(n,i){var o=Jg.registeredVariables[n];null==t.accumulatedFirstMoment[i]&&(t.accumulatedFirstMoment[i]={originalName:n+"/m",variable:dx((function(){return zw(o).variable(!1)}))}),null==t.accumulatedSecondMoment[i]&&(t.accumulatedSecondMoment[i]={originalName:n+"/v",variable:dx((function(){return zw(o).variable(!1)}))});var s=Array.isArray(e)?e[i].tensor:e[n];if(null!=s){var u=t.accumulatedFirstMoment[i].variable,l=t.accumulatedSecondMoment[i].variable,c=xx(Nx(u,t.beta1),Nx(s,1-t.beta1)),p=xx(Nx(l,t.beta2),Nx(Vk(s),1-t.beta2)),h=kx(c,r),f=kx(p,a);u.assign(c),l.assign(p);var d=xx(Nx(kx(h,xx(ZN(f),t.epsilon)),-t.learningRate),o);o.assign(d)}})),t.accBeta1.assign(Nx(t.accBeta1,t.beta1)),t.accBeta2.assign(Nx(t.accBeta2,t.beta2))})),this.incrementIterations()},n.dispose=function(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&mx(this.accumulatedFirstMoment.map((function(e){return e.variable}))),null!=this.accumulatedSecondMoment&&mx(this.accumulatedSecondMoment.map((function(e){return e.variable})))},n.getWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(this.accumulatedFirstMoment,this.accumulatedSecondMoment),e.next=3,this.saveIterations();case 3:return e.t0=e.sent,e.abrupt("return",[e.t0].concat(t.map((function(e){return{name:e.originalName,tensor:e.variable}}))));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:t=e.sent,dx((function(){r.accBeta1.assign(rN(r.beta1,r.iterations_+1)),r.accBeta2.assign(rN(r.beta2,r.iterations_+1))})),n=t.length/2,!1,this.accumulatedFirstMoment=t.slice(0,n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),this.accumulatedSecondMoment=t.slice(n,2*n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}}));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon}},t.fromConfig=function(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon)},t}(qS);YS.className="Adam",ax(YS);var JS=function(e){function t(t,n,r,a,i){var o;return void 0===a&&(a=null),void 0===i&&(i=0),(o=e.call(this)||this).learningRate=t,o.beta1=n,o.beta2=r,o.epsilon=a,o.decay=i,o.accumulatedFirstMoment=[],o.accumulatedWeightedInfNorm=[],dx((function(){o.iteration=_N(0).variable(),o.accBeta1=_N(n).variable()})),null==a&&(o.epsilon=Jg.backend.epsilon()),o}qm(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this,n=Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e);dx((function(){var r=vk(1,t.accBeta1),a=kx(-t.learningRate,xx(Nx(t.iteration,t.decay),1));n.forEach((function(n,i){var o=Jg.registeredVariables[n];null==t.accumulatedFirstMoment[i]&&(t.accumulatedFirstMoment[i]={originalName:n+"/m",variable:zw(o).variable(!1)}),null==t.accumulatedWeightedInfNorm[i]&&(t.accumulatedWeightedInfNorm[i]={originalName:n+"/v",variable:zw(o).variable(!1)});var s=Array.isArray(e)?e[i].tensor:e[n];if(null!=s){var u=t.accumulatedFirstMoment[i].variable,l=t.accumulatedWeightedInfNorm[i].variable,c=xx(Nx(u,t.beta1),Nx(s,1-t.beta1)),p=Nx(l,t.beta2),h=Ix(s),f=Mk(p,h);u.assign(c),l.assign(f);var d=xx(Nx(kx(a,r),kx(c,xx(f,t.epsilon))),o);o.assign(d)}})),t.iteration.assign(xx(t.iteration,1)),t.accBeta1.assign(Nx(t.accBeta1,t.beta1))})),this.incrementIterations()},n.dispose=function(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&mx(this.accumulatedFirstMoment.map((function(e){return e.variable}))),null!=this.accumulatedWeightedInfNorm&&mx(this.accumulatedWeightedInfNorm.map((function(e){return e.variable})))},n.getWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("getWeights() is not implemented for Adamax yet.");case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("setWeights() is not implemented for Adamax yet.");case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay}},t.fromConfig=function(e,t){return new e(t.learningRate,t.beta1,t.beta2,t.epsilon,t.decay)},t}(qS);JS.className="Adamax",ax(JS);var ZS=function(e){function t(t){var n;return(n=e.call(this)||this).learningRate=t,n.setLearningRate(t),n}qm(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=Array.isArray(e)?e[r].tensor:e[n];if(null!=a){var i=Jg.registeredVariables[n];dx((function(){var e=xx(Nx(t.c,a),i);i.assign(e)}))}})),this.incrementIterations()},n.setLearningRate=function(e){this.learningRate=e,null!=this.c&&this.c.dispose(),this.c=vx(_N(-e))},n.dispose=function(){this.c.dispose()},n.getWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.saveIterations();case 2:return e.t0=e.sent,e.abrupt("return",[e.t0]);case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:if(0===(t=e.sent).length){e.next=5;break}throw new Error("SGD optimizer does not have settable weights.");case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate}},t.fromConfig=function(e,t){return new e(t.learningRate)},t}(qS);ZS.className="SGD",ax(ZS);var QS=function(e){function t(t,n,r){var a;return void 0===r&&(r=!1),(a=e.call(this,t)||this).learningRate=t,a.momentum=n,a.useNesterov=r,a.accumulations=[],a.m=_N(a.momentum),a}qm(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=Jg.registeredVariables[n];if(null==t.accumulations[r]){t.accumulations[r]={originalName:n+"/momentum",variable:dx((function(){return zw(a).variable(!1)}))}}var i=t.accumulations[r].variable,o=Array.isArray(e)?e[r].tensor:e[n];null!=o&&dx((function(){var e,n=xx(Nx(t.m,i),o);e=t.useNesterov?xx(Nx(t.c,xx(o,Nx(n,t.m))),a):xx(Nx(t.c,n),a),i.assign(n),a.assign(e)}))})),this.incrementIterations()},n.dispose=function(){this.m.dispose(),null!=this.accumulations&&mx(this.accumulations.map((function(e){return e.variable})))},n.setMomentum=function(e){this.momentum=e},n.getWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.saveIterations();case 2:return e.t0=e.sent,e.abrupt("return",[e.t0].concat(this.accumulations.map((function(e){return{name:e.originalName,tensor:e.variable}}))));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:t=e.sent,!1,this.accumulations=t.map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}}));case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov}},t.fromConfig=function(e,t){return new e(t.learningRate,t.momentum,t.useNesterov)},t}(ZS);QS.className="Momentum",ax(QS);var $S=function(e){function t(t,n,r,a,i){var o;if(void 0===n&&(n=.9),void 0===r&&(r=0),void 0===a&&(a=null),void 0===i&&(i=!1),(o=e.call(this)||this).learningRate=t,o.decay=n,o.momentum=r,o.epsilon=a,o.accumulatedMeanSquares=[],o.accumulatedMoments=[],o.accumulatedMeanGrads=[],o.centered=i,null==a&&(o.epsilon=Jg.backend.epsilon()),null==t)throw new Error("learningRate for RMSPropOptimizer must be defined.");return o}qm(t,e);var n=t.prototype;return n.applyGradients=function(e){var t=this;(Array.isArray(e)?e.map((function(e){return e.name})):Object.keys(e)).forEach((function(n,r){var a=Jg.registeredVariables[n];null==t.accumulatedMeanSquares[r]&&(t.accumulatedMeanSquares[r]={originalName:n+"/rms",variable:dx((function(){return zw(a).variable(!1)}))}),null==t.accumulatedMoments[r]&&(t.accumulatedMoments[r]={originalName:n+"/momentum",variable:dx((function(){return zw(a).variable(!1)}))}),null==t.accumulatedMeanGrads[r]&&t.centered&&(t.accumulatedMeanGrads[r]={originalName:n+"/mg",variable:dx((function(){return zw(a).variable(!1)}))});var i=Array.isArray(e)?e[r].tensor:e[n];if(null!=i){var o=t.accumulatedMeanSquares[r].variable,s=t.accumulatedMoments[r].variable;dx((function(){var e=xx(Nx(o,t.decay),Nx(Vk(i),1-t.decay));if(t.centered){var n=t.accumulatedMeanGrads[r].variable,u=xx(Nx(n,t.decay),Nx(i,1-t.decay)),l=kx(Nx(i,t.learningRate),ZN(vk(e,xx(Vk(u),t.epsilon)))),c=xx(Nx(s,t.momentum),l);o.assign(e),n.assign(u),s.assign(c);var p=vk(a,c);a.assign(p)}else{var h=xx(Nx(o,t.decay),Nx(Vk(i),1-t.decay)),f=xx(Nx(s,t.momentum),kx(Nx(i,t.learningRate),ZN(xx(h,t.epsilon))));o.assign(h),s.assign(f);var d=vk(a,f);a.assign(d)}}))}})),this.incrementIterations()},n.dispose=function(){null!=this.accumulatedMeanSquares&&mx(this.accumulatedMeanSquares.map((function(e){return e.variable}))),null!=this.accumulatedMeanGrads&&this.centered&&mx(this.accumulatedMeanGrads.map((function(e){return e.variable}))),null!=this.accumulatedMoments&&mx(this.accumulatedMoments.map((function(e){return e.variable})))},n.getWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[].concat(this.accumulatedMeanSquares,this.accumulatedMoments),this.centered&&t.push.apply(t,this.accumulatedMeanGrads),e.next=4,this.saveIterations();case 4:return e.t0=e.sent,e.abrupt("return",[e.t0].concat(t.map((function(e){return{name:e.originalName,tensor:e.variable}}))));case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setWeights=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.extractIterations(t);case 2:t=e.sent,n=this.centered?t.length/3:t.length/2,!1,this.accumulatedMeanSquares=t.slice(0,n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),this.accumulatedMoments=t.slice(n,2*n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})),this.centered&&(this.accumulatedMeanGrads=t.slice(2*n,3*n).map((function(e){return{originalName:e.name,variable:e.tensor.variable(!1)}})));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getConfig=function(){return{learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered}},t.fromConfig=function(e,t){return new e(t.learningRate,t.decay,t.momentum,t.epsilon,t.centered)},t}(qS);$S.className="RMSProp",ax($S);var eT=function(){function e(){}return e.sgd=function(e){return new ZS(e)},e.momentum=function(e,t,n){return void 0===n&&(n=!1),new QS(e,t,n)},e.rmsprop=function(e,t,n,r,a){return void 0===t&&(t=.9),void 0===n&&(n=0),void 0===r&&(r=null),void 0===a&&(a=!1),new $S(e,t,n,r,a)},e.adam=function(e,t,n,r){return void 0===e&&(e=.001),void 0===t&&(t=.9),void 0===n&&(n=.999),void 0===r&&(r=null),new YS(e,t,n,r)},e.adadelta=function(e,t,n){return void 0===e&&(e=.001),void 0===t&&(t=.95),void 0===n&&(n=null),new KS(e,t,n)},e.adamax=function(e,t,n,r,a){return void 0===e&&(e=.002),void 0===t&&(t=.9),void 0===n&&(n=.999),void 0===r&&(r=null),void 0===a&&(a=0),new JS(e,t,n,r,a)},e.adagrad=function(e,t){return void 0===t&&(t=.1),new XS(e,t)},e}(),tT={sgd:eT.sgd,momentum:eT.momentum,adadelta:eT.adadelta,adagrad:eT.adagrad,rmsprop:eT.rmsprop,adamax:eT.adamax,adam:eT.adam},nT="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:function(e){return e()};function rT(){return new Promise((function(e){return nT((function(){return e()}))}))}function aT(e,t){var n=e[0].length;e.forEach((function(e,t){lv(e.length===n,(function(){return"Error in concat"+n+"D: rank of tensors["+t+"] must be the same as the rank of the rest ("+n+")"}))})),lv(t>=0&&t<n,(function(){return"Error in concat"+n+"D: axis must be between 0 and "+(n-1)+"."}));var r=e[0];e.forEach((function(e,a){for(var i=0;i<n;i++)lv(i===t||e[i]===r[i],(function(){return"Error in concat"+n+"D: Shape of tensors["+a+"] ("+e+") does not match the shape of the rest ("+r+") along the non-concatenated axis "+a+"."}))}))}function iT(e,t){for(var n=e[0].slice(),r=1;r<e.length;r++)n[t]+=e[r][t];return n}function oT(e){return e<=30?e:Mv(e,Math.floor(Math.sqrt(e)))}function sT(e,t,n){return[n*("number"==typeof e?e:e[0]),t*("number"==typeof e?e:e[1])]}function uT(e,t,n,r){void 0===r&&(r=!0);var a=[];if(r)(a=a.concat(t.slice(0))).push(e[0]/n),a=a.concat(e.slice(1));else{a=a.concat(e[0]);for(var i=t.length,o=0;o<i;++o)a=a.concat([e[o+1]/t[o],t[o]]);a=a.concat(e.slice(i+1))}return a}function lT(e,t,n){void 0===n&&(n=!0);var r=[];if(n){r.push(t);for(var a=t+1;a<e;++a)a<=2*t?(r.push(a),r.push(a-(t+1))):r.push(a)}else{for(var i=[],o=[],s=1;s<e;++s)s>=2*t+1||s%2==1?o.push(s):i.push(s);r.push.apply(r,i),r.push(0),r.push.apply(r,o)}return r}function cT(e,t,n,r){void 0===r&&(r=!0);var a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(var i=1;i<e.length;++i)i<=t.length?r?a.push(t[i-1]*e[i]):a.push(e[i]/t[i-1]):a.push(e[i]);return a}function pT(e,t){for(var n=[0],r=0;r<t;++r)n.push(e[r][0]);return n}function hT(e,t,n){for(var r=e.slice(0,1),a=0;a<n;++a)r.push(e[a+1]-t[a][0]-t[a][1]);return r}var fT=1.0507009873554805;function dT(){var e;Xv().getBool("IS_TEST")||(e=console).warn.apply(e,arguments)}function mT(e,t){if(e.length!==t.length)throw new Error("Cannot merge real and imag arrays of different lengths. real:"+e.length+", imag: "+t.length+".");for(var n=new Float32Array(2*e.length),r=0;r<n.length;r+=2)n[r]=e[r/2],n[r+1]=t[r/2];return n}function vT(e){for(var t=new Float32Array(e.length/2),n=new Float32Array(e.length/2),r=0;r<e.length;r+=2)t[r/2]=e[r],n[r/2]=e[r+1];return{real:t,imag:n}}function gT(e){for(var t=Math.ceil(e.length/4),n=new Float32Array(t),r=new Float32Array(t),a=0;a<e.length;a+=4)n[Math.floor(a/4)]=e[a],r[Math.floor(a/4)]=e[a+1];return{real:n,imag:r}}function yT(e){for(var t=Math.floor(e.length/4),n=new Float32Array(t),r=new Float32Array(t),a=2;a<e.length;a+=4)n[Math.floor(a/4)]=e[a],r[Math.floor(a/4)]=e[a+1];return{real:n,imag:r}}function bT(e,t){return{real:e[2*t],imag:e[2*t+1]}}function xT(e,t,n,r){e[2*r]=t,e[2*r+1]=n}function wT(e,t){for(var n=new Float32Array(e/2),r=new Float32Array(e/2),a=0;a<Math.ceil(e/2);a++){var i=(t?2:-2)*Math.PI*(a/e);n[a]=Math.cos(i),r[a]=Math.sin(i)}return{real:n,imag:r}}function kT(e,t,n){var r=(n?2:-2)*Math.PI*(e/t);return{real:Math.cos(r),imag:Math.sin(r)}}function NT(e,t,n){void 0===n&&(n=0);var r=[];if("number"==typeof t)lv(e.shape[n]%t==0,(function(){return"Number of splits must evenly divide the axis."})),r=new Array(t).fill(e.shape[n]/t);else{lv(t.reduce((function(e,t){return-1===t&&(e+=1),e}),0)<=1,(function(){return"There should be only one negative value in split array."}));var a=t.indexOf(-1);if(-1!==a){var i=t.reduce((function(e,t){return t>0?e+t:e}));t[a]=e.shape[n]-i}lv(e.shape[n]===t.reduce((function(e,t){return e+t})),(function(){return"The sum of sizes must match the size of the axis dimension."})),r=t}return r}function IT(e,t){var n,r=!1;for(e<=30?(n=e,r=!0):n=Mv(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=Mv(e,n+1);return n}function ST(e,t,n){for(var r=[],a=e.length,i=0;i<a;i++)i!==t?r.push(e[i]):r.push(n);return r}function TT(e,t,n,r){var a=t.shape.length,i=e.shape.length;if(0!==r&&(r<-a||r>a))throw new Error("Expect batchDims in the range of [-"+a+", "+a+"], but got "+r);if(r<0&&(r+=a),r>i)throw new Error("batchDims ("+r+") must be less than rank(x) (\n    "+i+").");if(n<r)throw new Error("batchDims ("+r+") must be less than or equal to axis ("+n+").");for(var o=0;o<r;++o)if(e.shape[o]!==t.shape[o])throw new Error("x.shape["+o+"]: "+e.shape[o]+" should be equal to indices.shape["+o+"]: "+t.shape[o]+".");for(var s=e.shape[n],u=[],l=1,c=1,p=1,h=0;h<r;++h)u.push(e.shape[h]),l*=e.shape[h];for(var f=r;f<n;f++)u.push(e.shape[f]),c*=e.shape[f];for(var d=r;d<a;d++)u.push(t.shape[d]);for(var m=n+1;m<i;m++)u.push(e.shape[m]),p*=e.shape[m];return{batchSize:l,sliceSize:p,outerSize:c,dimSize:s,outputShape:u}}function CT(e){try{return e.map((function(e){return wg(e)}))}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8, error: "+e)}}function ET(e){return e.map((function(e){return xg(e)}))}var RT={__proto__:null,slice_util:tx,segment_util:{__proto__:null,segOpComputeOptimalWindowSize:IT,computeOutShape:ST,collectGatherOpShapeInfo:TT},castTensor:function(e,t,n){if("complex64"===t){if("complex64"===e.dtype)return e.clone();var r=qk(e.shape),a=rb(e,"float32"),i=n.complex(a,r);return r.dispose(),a.dispose(),i}if(!Tv(e.dtype,t))return Jg.makeTensorFromDataId(e.dataId,e.shape,t);if("complex64"===e.dtype){var o=n.real(e),s=rb(o,t);return o.dispose(),s}if("int32"===t)return n.int(e);if("bool"===t){var u=_N(0,e.dtype),l=n.notEqual(e,u);return u.dispose(),l}throw new Error("Error in Cast: failed to cast "+e.dtype+" to "+t)},reshapeTensor:function(e,t){return Jg.makeTensorFromDataId(e.dataId,t,e.dtype)},fromUint8ToStringArray:CT,fromStringArrayToUint8:ET,upcastType:Wg,axesAreInnerMostDims:bk,combineLocations:xk,computeOutAndReduceShapes:wk,expandShapeToKeepDim:kk,assertAxesAreInnerMostDims:Nk,getAxesPermutation:Ik,getUndoAxesPermutation:Sk,getInnerMostAxes:Tk,getBroadcastDims:Fw,getReductionAxes:_w,assertAndGetBroadcastShape:Ow,assertParamsConsistent:aT,computeOutShape:iT,computeDilation2DInfo:zx,computePool2DInfo:Px,computePool3DInfo:Bx,computeConv2DInfo:Wx,computeConv3DInfo:Vx,computeDefaultPad:Ux,tupleValuesAreOne:Kx,eitherStridesOrDilationsAreOne:Xx,convertConv2DDataFormat:Yx,getFusedDyActivation:GI,getFusedBiasGradient:jI,applyActivation:HI,shouldFuse:qI,PARALLELIZE_THRESHOLD:30,computeOptimalWindowSize:oT,getImageCenter:sT,getReshaped:uT,getPermuted:lT,getReshapedPermuted:cT,getSliceBeginCoords:pT,getSliceSize:hT,prepareAndValidate:_b,validateUpdateShape:Mb,validateInput:Lb,calculateShapes:zb,SELU_SCALEALPHA:1.7580993408473768,SELU_SCALE:fT,ERF_P:.3275911,ERF_A1:.254829592,ERF_A2:-.284496736,ERF_A3:1.421413741,ERF_A4:-1.453152027,ERF_A5:1.061405429,warn:dT,log:function(){var e;Xv().getBool("IS_TEST")||(e=console).log.apply(e,arguments)},mergeRealAndImagArrays:mT,splitRealAndImagArrays:vT,complexWithEvenIndex:gT,complexWithOddIndex:yT,getComplexWithIndex:bT,assignToTypedArray:xT,exponents:wT,exponent:kT,prepareSplitSize:NT},AT={__proto__:null,nonMaxSuppressionV3Impl:cS,nonMaxSuppressionV4Impl:pS,nonMaxSuppressionV5Impl:hS,whereImpl:hI},DT={kernelName:"Abs",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(e,tI(rb(n,"float32"),-1))}}}},FT={kernelName:"Acos",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){var t=Vk(rb(n,"float32")),r=ZN(vk(_N(1),t));return hk(kx(e,r))}}}},_T={kernelName:"Acosh",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){var t=ZN(vk(Vk(rb(n,"float32")),1));return kx(e,t)}}}},OT={kernelName:Zv,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=Ow(n.shape,r.shape);return{a:function(){var t=e,r=_w(n.shape,a);return r.length>0&&(t=gk(t,r)),Jx(t,n.shape)},b:function(){var t=e,n=_w(r.shape,a);return n.length>0&&(t=gk(t,n)),Jx(t,r.shape)}}}},MT={kernelName:"AddN",saveAllInputs:!0,gradFunc:function(e,t){var n={};return t.forEach((function(t,r){n[r]=function(){return e.clone()}})),n}},LT={kernelName:"ArgMax",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return zw(n)}}}},zT={kernelName:"ArgMin",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return zw(n)}}}},PT={kernelName:"Asin",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return kx(e,ZN(vk(_N(1),Vk(rb(n,"float32")))))}}}},BT={kernelName:"Asinh",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){var t=ZN(xx(_N(1),Vk(rb(n,"float32"))));return kx(e,t)}}}},WT={kernelName:"Atan2",inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=Ow(n.shape,r.shape);return{a:function(){var t=xx(Vk(n),Vk(r)),i=Nx(e,kx(r,t)),o=_w(n.shape,a);return o.length>0&&(i=gk(i,o)),Jx(i,n.shape)},b:function(){var t=xx(Vk(n),Vk(r)),i=hk(Nx(e,kx(n,t))),o=_w(r.shape,a);return o.length>0&&(i=gk(i,o)),Jx(i,r.shape)}}}},VT={kernelName:"Atan",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return kx(e,xx(Vk(rb(n,"float32")),1))}}}},UT={kernelName:"Atanh",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return kx(e,vk(_N(1),Vk(rb(n,"float32"))))}}}};var GT=oy({avgPool3dGrad_:function(e,t,n,r,a,i,o){void 0===a&&(a=[1,1,1]);var s=ay(e,"dy","avgPool3dGrad"),u=ay(t,"input","avgPool3dGrad"),l=s,c=u,p=!1;4===u.rank&&(p=!0,l=Jx(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]]),c=Jx(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]])),lv(5===l.rank,(function(){return"Error in avgPool3dGrad: dy must be rank 5 but got rank "+l.rank+"."})),lv(5===c.rank,(function(){return"Error in avgPool3dGrad: input must be rank 5 but got rank "+c.rank+"."})),lv(Xx(r,a),(function(){return"Error in avgPool3dGrad: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+a+"'"})),null!=o&&lv(mv(i),(function(){return"Error in avgPool3dGrad: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+i+"."}));var h={dy:l,input:c},f={filterSize:n,strides:r,dilations:a,pad:i,dimRoundingMode:o},d=Jg.runKernel("AvgPool3DGrad",h,f);return p?Jx(d,[d.shape[1],d.shape[2],d.shape[3],d.shape[4]]):d}}),jT={kernelName:"AvgPool3D",inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.filterSize,i=n.strides,o=n.dilations,s=n.pad,u=n.dimRoundingMode,l=null==o?[1,1,1]:o;return{x:function(){return GT(e,r,a,i,l,s,u)}}}};var HT=oy({avgPoolGrad_:function(e,t,n,r,a){var i=ay(e,"dy","avgPoolGrad"),o=ay(t,"input","avgPoolGrad");lv(o.rank===i.rank,(function(){return"Rank of input ("+o.rank+") does not match rank of dy ("+i.rank+")"}));var s=o,u=i,l=!1;3===o.rank&&(l=!0,s=Jx(o,[1,o.shape[0],o.shape[1],o.shape[2]]),u=Jx(i,[1,i.shape[0],i.shape[1],i.shape[2]])),lv(4===u.rank,(function(){return"Error in avgPoolGrad: dy must be rank 4 but got rank "+u.rank+"."})),lv(4===s.rank,(function(){return"Error in avgPoolGrad: input must be rank 4 but got rank "+s.rank+"."}));var c={dy:u,input:s},p={filterSize:n,strides:r,pad:a},h=Jg.runKernel("AvgPoolGrad",c,p);return l?Jx(h,[h.shape[1],h.shape[2],h.shape[3]]):h}}),qT={kernelName:"AvgPool",inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.filterSize,i=n.strides,o=n.pad;return{x:function(){return HT(e,r,a,i,o)}}}},KT={kernelName:"BatchMatMul",inputsToSave:["a","b"],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.transposeA,o=n.transposeB;return i||o?!i&&o?{a:function(){return Ib(e,a,!1,!1)},b:function(){return Ib(e,r,!0,!1)}}:i&&!o?{a:function(){return Ib(a,e,!1,!0)},b:function(){return Ib(r,e,!1,!1)}}:{a:function(){return Ib(a,e,!0,!0)},b:function(){return Ib(e,r,!0,!0)}}:{a:function(){return Ib(e,a,!1,!0)},b:function(){return Ib(r,e,!0,!1)}}}},XT={kernelName:"BatchToSpaceND",gradFunc:function(e,t,n){var r=n.blockShape,a=n.crops;return{x:function(){return tN(e,r,a)}}}},YT={kernelName:"BroadcastTo",gradFunc:function(e,t,n){for(var r=n,a=r.inputShape,i=r.shape,o=Array.from(i),s=a.length-1;s>=0;s--)if(a[s]===i[s])o[s]=1;else if(1!==a[s])throw new Error("broadcastTo(): ["+a+"] cannot be broadcast to ["+i+"].");for(var u=[],l=0;l<o.length;l++)o[l]>1&&u.push(l);return{x:function(){return gk(e,u,!0)}}}},JT={kernelName:"Cast",gradFunc:function(e){return{x:function(){return e.clone()}}}},ZT={kernelName:"Ceil",gradFunc:function(e){return{x:function(){return zw(e)}}}},QT={kernelName:"ClipByValue",inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.clipValueMin,i=n.clipValueMax;return{x:function(){return Lw(Ek(Zw(r,a),ak(r,i)),e,zw(e))}}}},$T={kernelName:"ComplexAbs",inputsToSave:["x"],gradFunc:DT.gradFunc},eC={kernelName:"Concat",saveAllInputs:!0,gradFunc:function(e,t,n){var r=t.map((function(e){return e.shape})),a=xv(n.axis,t[0].shape)[0],i=r.map((function(e){return e[a]}));return YN(e,i,a).map((function(e){return function(){return e}}))}},tC={kernelName:"Conv2D",inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.dilations,o=n.strides,s=n.pad,u=n.dataFormat;return lv(Kx(i),(function(){return"Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+i+"'"})),{x:function(){return bw(r.shape,e,a,o,s,u)},filter:function(){return UI(r,e,a.shape,o,s,u)}}}},nC={kernelName:"Conv2DBackpropInput",inputsToSave:["dy","filter"],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.strides,o=n.pad,s=n.dataFormat,u=n.dimRoundingMode;return{dy:function(){return gw(e,a,i,o,s,1,u)},filter:function(){return UI(e,r,a.shape,i,o,s,u)}}}};var rC=oy({conv3DBackpropFilter_:function(e,t,n,r,a){var i=e;4===e.rank&&(i=Jx(e,[1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]]));var o=t;4===o.rank&&(o=Jx(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]])),lv(5===i.rank,(function(){return"Error in conv3dDerFilter: input must be rank 5, but got shape "+i.shape+"."})),lv(5===o.rank,(function(){return"Error in conv3dDerFilter: dy must be rank 5, but got shape "+o.shape+"."})),lv(5===n.length,(function(){return"Error in conv3dDerFilter: filterShape must be length 5, but got "+n+"."})),lv(i.shape[4]===n[3],(function(){return"Error in conv3dDerFilter: depth of input "+i.shape[4]+") must match input depth in filter ("+n[3]+"."})),lv(o.shape[4]===n[4],(function(){return"Error in conv3dDerFilter: depth of dy ("+o.shape[4]+") must match output depth for filter ("+n[4]+")."}));var s={x:i,dy:o},u={strides:r,pad:a,filterShape:n};return Jg.runKernel("Conv3DBackpropFilterV2",s,u)}}),aC={kernelName:"Conv3D",inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=n.dilations,a=n.strides,i=n.pad;lv(Kx(r),(function(){return"Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+r+"'"}));var o=t[0],s=t[1];return{x:function(){return kw(o.shape,e,s,a,i)},filter:function(){return rC(o,e,s.shape,a,i)}}}},iC={kernelName:Qv,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(hk(BN(rb(n,"float32"))),e)}}}},oC={kernelName:"Cosh",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(WN(rb(n,"float32")),e)}}}},sC={kernelName:"Cumsum",inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.axis,i=n.exclusive,o=n.reverse;return{x:function(){var t=Ik([a],r.rank),n=Tw(e,a,i,!o);return null!=t&&(n=Tb(n,t)),n}}}},uC={kernelName:"DepthwiseConv2dNative",inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=n.dilations,a=n.strides,i=n.pad,o=n.dimRoundingMode,s=null==r?[1,1]:r;lv(Kx(s),(function(){return"Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '"+s+"'"}));var u=t[0],l=t[1];return lv(4===u.rank,(function(){return"Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank "+u.rank+"."})),lv(4===l.rank,(function(){return"Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank "+l.rank+"."})),lv(u.shape[3]===l.shape[2],(function(){return"Error in gradient of depthwiseConv2d: number of input channels ("+u.shape[3]+") must match the inChannels dimension in filter "+l.shape[2]+"."})),lv(Xx(a,s),(function(){return"Error in gradient of depthwiseConv2d: Either strides or dilations must be  1. Got strides "+a+" and dilations '"+s+"'."})),null!=o&&lv(mv(i),(function(){return"Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+i+"."})),{x:function(){return YI(u.shape,e,l,a,i,r,o)},filter:function(){return XI(u,e,l.shape,a,i,r,o)}}}},lC={kernelName:"Dilation2D",inputsToSave:["x","filter"],gradFunc:function(e,t,n){var r=t[0],a=t[1],i={x:r,filter:a,dy:e},o={x:r,filter:a,dy:e};return{x:function(){return Jg.runKernel("Dilation2DBackpropInput",i,n)},filter:function(){return Jg.runKernel("Dilation2DBackpropFilter",o,n)}}}},cC={kernelName:$v,outputsToSave:[!0],gradFunc:function(e,t){var n={dy:e,y:t[0]};return{x:function(){return Jg.runKernel("EluGrad",n)}}}},pC={kernelName:eg,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0],r=Nx(Uw(hk(Vk(n))),2/Math.sqrt(Math.PI));return{x:function(){return Nx(e,r)}}}},hC={kernelName:tg,outputsToSave:[!0],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(e,n)}}}},fC={kernelName:"ExpandDims",inputsToSave:["input"],gradFunc:function(e,t){var n=t[0];return{input:function(){return Jx(e,n.shape)}}}},dC={kernelName:"Expm1",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(e,Uw(n))}}}},mC={kernelName:"Floor",gradFunc:function(e){return{x:function(){return zw(e)}}}},vC={kernelName:"FloorDiv",inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=Ow(n.shape,r.shape);return{a:function(){var t=kx(e,rb(r,"float32")),i=_w(n.shape,a);return i.length>0?Jx(gk(t,i),n.shape):t},b:function(){var t=Nx(e,rb(n,"float32")),i=_w(r.shape,a);i.length>0&&(t=Jx(gk(t,i),r.shape));var o=Vk(r);return hk(kx(t,rb(o,"float32")))}}}},gC={kernelName:"FusedBatchNorm",inputsToSave:["x","mean","variance","scale"],gradFunc:function(e,t,n){var r=n.varianceEpsilon,a=t[0],i=t[1],o=t[2],s=t[3],u=null==s?_N(1):s,l=_w(i.shape,a.shape),c=[];if(1===i.rank){for(var p=0;p<a.shape.length-1;++p)c.push(a.shape[p]);c.push(1)}var h=vk(a,i),f=Nx(e,u),d=FN(xx(o,_N(r))),m=Nx(Nx(Nx(d,d),d),_N(-.5));return{x:function(){return 1===i.rank?Jx(Nx(Nx(e,Hw(Jx(d,[1,1,1,i.shape[0]]),c)),u),a.shape):Jx(Nx(Nx(e,d),u),a.shape)},mean:function(){var e=Nx(Nx(d,_N(-1)),f);return 1===i.rank&&(e=gk(e,l)),Jx(e,i.shape)},variance:function(){var e=Nx(Nx(m,h),f);return 1===i.rank&&(e=gk(e,l)),Jx(e,i.shape)},scale:function(){var t=Nx(h,d),n=Nx(e,t);return 1===i.rank&&(n=gk(n,l)),Jx(n,i.shape)},offset:function(){var t=e;return 1===i.rank&&(t=gk(t,l)),Jx(t,i.shape)}}}},yC={kernelName:"GatherV2",inputsToSave:["x","indices"],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.axis,o=xv(i,r.shape)[0];return{x:function(){var t=r.shape,n=a.size,s=t.slice(0,o),u=s.length,l=t.slice(i,t.length).slice(1),c=l.length,p=bC(0,u),h=bC(u+1,u+1+c),f=xC([s,[n],l]),d=Jx(e,f),m=Jx(a,[n]),v=xC([[u],p,h]),g=Tb(d,v),y=lI(g,m,r.shape[o]),b=Sk(v);return y=Tb(y,b)},indices:function(){return a}}}};function bC(e,t){for(var n=[],r=e;r<t;++r)n.push(r);return n}function xC(e){for(var t=[],n=0;n<e.length;++n)for(var r=0;r<e[n].length;++r)t.push(e[n][r]);return t}var wC={kernelName:"GreaterEqual",inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1];return{a:function(){return zw(n)},b:function(){return zw(r)}}}},kC={kernelName:"Identity",gradFunc:function(e){return{x:function(){return rb(e,"float32")}}}},NC={kernelName:"IsFinite",gradFunc:function(e){return{x:function(){return zw(e)}}}},IC={kernelName:"IsInf",gradFunc:function(e){return{x:function(){return zw(e)}}}},SC={kernelName:"IsNan",gradFunc:function(e){return{x:function(){return zw(e)}}}},TC={kernelName:"LeakyRelu",inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.alpha,i=Jw(r,0);return{x:function(){return Lw(i,e,Nx(e,a))}}}},CC={kernelName:"Log1p",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return kx(e,xx(n,1))}}}},EC={kernelName:ng,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return kx(e,rb(n,"float32"))}}}},RC={kernelName:"LogSoftmax",inputsToSave:[],outputsToSave:[!0],gradFunc:function(e,t,n){var r=t[0],a=n.axis;return{logits:function(){var t=Uw(r);return vk(e,Nx(gk(e,a,!0),t))}}}};var AC=oy({localResponseNormalizationBackprop_:function(e,t,n,r,a,i,o){void 0===r&&(r=5),void 0===a&&(a=1),void 0===i&&(i=1),void 0===o&&(o=.5);var s={x:e,y:t,dy:n},u={depthRadius:r,bias:a,alpha:i,beta:o};return Jg.runKernel("LRNGrad",s,u)}}),DC={kernelName:"LRN",inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.depthRadius,o=n.bias,s=n.alpha,u=n.beta;return{x:function(){return AC(r,a,e,i,o,s,u)}}}};function FC(e,t,n,r){return t.rank<n.rank&&(t=Jx(t,kk(t.shape,r))),e.rank<n.rank&&(e=Jx(e,kk(e.shape,r))),{x:function(){return Nx(e,rb(Mw(n,t),e.dtype))}}}var _C={kernelName:"Max",inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(e,t,n){var r=n.reductionIndices,a=t[0],i=FC(e,t[1],a,xv(r,a.shape));return{x:function(){return i.x()}}}},OC={kernelName:"Maximum",inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1];return{a:function(){return Nx(e,rb(Zw(n,r),"float32"))},b:function(){return Nx(e,rb(rk(n,r),"float32"))}}}};var MC=oy({maxPool3dGrad_:function(e,t,n,r,a,i,o,s){void 0===i&&(i=[1,1,1]);var u=ay(e,"dy","maxPool3dGrad"),l=ay(t,"input","maxPool3dGrad"),c=ay(n,"output","maxPool3dGrad"),p=u,h=l,f=c,d=!1;4===l.rank&&(d=!0,p=Jx(u,[1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]]),h=Jx(l,[1,l.shape[0],l.shape[1],l.shape[2],l.shape[3]]),f=Jx(c,[1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]])),lv(5===p.rank,(function(){return"Error in maxPool3dGrad: dy must be rank 5 but got rank "+p.rank+"."})),lv(5===h.rank,(function(){return"Error in maxPool3dGrad: input must be rank 5 but got rank "+h.rank+"."})),lv(5===f.rank,(function(){return"Error in maxPool3dGrad: output must be rank 5 but got rank "+f.rank+"."})),lv(Xx(a,i),(function(){return"Error in maxPool3dGrad: Either strides or dilations must be 1. Got strides "+a+" and dilations '"+i+"'"})),null!=s&&lv(mv(o),(function(){return"Error in maxPool3dGrad: pad must be an integer when using, dimRoundingMode "+s+" but got pad "+o+"."}));var m={dy:p,input:h,output:f},v={filterSize:r,strides:a,dilations:i,pad:o,dimRoundingMode:s},g=Jg.runKernel("MaxPool3DGrad",m,v);return d?Jx(g,[g.shape[1],g.shape[2],g.shape[3],g.shape[4]]):g}}),LC={kernelName:"MaxPool3D",inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.filterSize,o=n.strides,s=n.dilations,u=n.pad,l=n.dimRoundingMode,c=null==s?[1,1,1]:s;return{x:function(){return MC(e,r,a,i,o,c,u,l)}}}};var zC=oy({maxPoolGrad_:function(e,t,n,r,a,i,o){var s=ay(e,"dy","maxPoolGrad"),u=ay(t,"input","maxPoolGrad"),l=ay(n,"output","maxPoolGrad");lv(u.rank===s.rank,(function(){return"Rank of input ("+u.rank+") does not match rank of dy ("+s.rank+")"})),lv(4===s.rank,(function(){return"Error in maxPoolGrad: dy must be rank 4 but got rank "+s.rank+"."})),lv(4===u.rank,(function(){return"Error in maxPoolGrad: input must be rank 4 but got rank "+u.rank+"."})),null!=o&&lv(mv(i),(function(){return"Error in maxPoolGrad: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+i+"."}));var c={dy:s,input:u,output:l},p={filterSize:r,strides:a,pad:i,dimRoundingMode:o};return Jg.runKernel("MaxPoolGrad",c,p)}}),PC={kernelName:"PadV2",inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.paddings.map((function(e){return e[0]}));return{x:function(){return tw(e,a,r.shape)}}}},BC={kernelName:"SpaceToBatchND",gradFunc:function(e,t,n){var r=n.blockShape,a=n.paddings;return{x:function(){return aw(e,r,a)}}}},WC={kernelName:"SplitV",gradFunc:function(e,t,n){var r=n.axis;return{x:function(){return $x(e,r)}}}},VC={kernelName:"Tile",inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.reps;return{x:function(){var t=zw(r);if(1===r.rank)for(var n=0;n<a[0];++n)t=xx(t,tw(e,[n*r.shape[0]],[r.shape[0]]));else if(2===r.rank)for(var i=0;i<a[0];++i)for(var o=0;o<a[1];++o)t=xx(t,tw(e,[i*r.shape[0],o*r.shape[1]],[r.shape[0],r.shape[1]]));else if(3===r.rank)for(var s=0;s<a[0];++s)for(var u=0;u<a[1];++u)for(var l=0;l<a[2];++l)t=xx(t,tw(e,[s*r.shape[0],u*r.shape[1],l*r.shape[2]],[r.shape[0],r.shape[1],r.shape[2]]));else{if(4!==r.rank)throw new Error("Gradient for tile operation is not implemented for rank-"+r.rank+" tensors yet.");for(var c=0;c<a[0];++c)for(var p=0;p<a[1];++p)for(var h=0;h<a[2];++h)for(var f=0;f<a[3];++f)t=xx(t,tw(e,[c*r.shape[0],p*r.shape[1],h*r.shape[2],f*r.shape[3]],[r.shape[0],r.shape[1],r.shape[2],r.shape[3]]))}return t}}}};for(var UC,GC=0,jC=[DT,FT,_T,OT,MT,LT,zT,PT,BT,WT,VT,UT,jT,qT,KT,XT,YT,JT,ZT,QT,$T,eC,nC,tC,aC,iC,oC,sC,uC,lC,{kernelName:"RealDiv",inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=Ow(n.shape,r.shape);return{a:function(){var t=kx(e,rb(r,"float32")),i=_w(n.shape,a);return i.length>0?Jx(gk(t,i),n.shape):t},b:function(){var t=Nx(e,rb(n,"float32")),i=_w(r.shape,a);i.length>0&&(t=Jx(gk(t,i),r.shape));var o=Vk(r);return hk(kx(t,rb(o,"float32")))}}}},cC,pC,hC,fC,dC,vC,mC,gC,yC,wC,kC,NC,IC,SC,TC,CC,EC,RC,DC,_C,_C,OC,LC,{kernelName:"MaxPool",inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(e,t,n){var r=t[0],a=t[1],i=n.filterSize,o=n.strides,s=n.pad;return{x:function(){return zC(e,r,a,i,o,s)}}}},{kernelName:"Mean",inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=xv(n.axis,r.shape),i=fv(wk(r.shape,a)[1]);return{x:function(){var t=r.shape.slice();a.forEach((function(e){t[e]=1}));var n=Jx(e,t);return kx(Nx(n,Kk(r.shape,"float32")),i)}}}},{kernelName:"Min",inputsToSave:["x"],outputsToSave:[!0],gradFunc:function(e,t,n){var r=n.axis,a=t[0],i=FC(e,t[1],a,xv(r,a.shape));return{x:function(){return i.x()}}}},{kernelName:"Minimum",inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1];return{a:function(){return Nx(e,rb(ak(n,r),"float32"))},b:function(){return Nx(e,rb(Jw(n,r),"float32"))}}}},{kernelName:"MirrorPad",inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=n.paddings.map((function(e){return e[0]}));return{x:function(){return tw(e,a,r.shape)}}}},{kernelName:rg,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=Ow(n.shape,r.shape);return{a:function(){var t=_w(n.shape,a);return t.length>0?Jx(gk(e,t),n.shape):e},b:function(){var t=Nx(e,hk(Xw(kx(n,r)))),i=_w(r.shape,a);return i.length>0?Jx(gk(t,i),r.shape):t}}}},{kernelName:"Multiply",inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=Ow(n.shape,r.shape);return{a:function(){var t=Nx(e,rb(r,"float32")),i=_w(n.shape,a);return i.length>0?Jx(gk(t,i),n.shape):t},b:function(){var t=Nx(e,rb(n,"float32")),i=_w(r.shape,a);return i.length>0?Jx(gk(t,i),r.shape):t}}}},{kernelName:"Neg",gradFunc:function(e){return{x:function(){return hk(e)}}}},{kernelName:"OneHot",inputsToSave:["indices"],gradFunc:function(e,t){var n=t[0];return{indices:function(){return qk(n.shape,"float32")}}}},{kernelName:"OnesLike",gradFunc:function(e){return{x:function(){return zw(e)}}}},{kernelName:"Pack",saveAllInputs:!0,gradFunc:function(e,t,n){var r=n.axis;return cI(e,r).map((function(e){return function(){return e}}))}},PC,PC,{kernelName:ag,inputsToSave:["a","b"],outputsToSave:[!0],gradFunc:function(e,t){var n=t[0],r=t[1],a=t[2],i=n,o=r,s=Ow(i.shape,o.shape);return{a:function(){var t=rb(o,"float32"),n=Nx(e,Nx(t,rN(i,vk(t,_N(1))))),r=_w(i.shape,s);return r.length>0&&(n=gk(n,r)),Jx(n,i.shape)},b:function(){var t=Jw(i,0),n=Lw(t,sk(i),zw(i)),r=Nx(e,Nx(a,n)),u=_w(o.shape,s);return u.length>0&&(r=gk(r,u)),Jx(r,o.shape)}}}},{kernelName:"Prelu",inputsToSave:["x","alpha"],gradFunc:function(e,t){var n=t[0],r=t[1],a=Jw(n,0);return{x:function(){return Lw(a,e,Nx(e,r))},alpha:function(){var t=Lw(a,zw(e),Nx(e,n)),i=_w(r.shape,e.shape);return i.length>0&&(t=gk(t,i)),Jx(t,r.shape)}}}},{kernelName:"Reciprocal",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return kx(e,hk(Vk(n)))}}}},{kernelName:"Relu6",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0],r=Nx(ak(n,6),tI(n));return{x:function(){return Nx(e,rb(r,"float32"))}}}},{kernelName:"Relu",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(e,rb(tI(n),"float32"))}}}},{kernelName:"Reshape",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return Jx(e,n.shape)}}}},{kernelName:"ResizeBilinear",inputsToSave:["images"],gradFunc:function(e,t,n){var r={dy:e,images:t[0]};return{images:function(){return Jg.runKernel("ResizeBilinearGrad",r,n)}}}},{kernelName:"ResizeNearestNeighbor",inputsToSave:["images"],gradFunc:function(e,t,n){var r={dy:e,images:t[0]};return{images:function(){return Jg.runKernel("ResizeNearestNeighborGrad",r,n)}}}},{kernelName:"Reverse",gradFunc:function(e,t,n){var r=xv(n.dims,e.shape);return{x:function(){return TN(e,r)}}}},{kernelName:"Round",gradFunc:function(e){return{x:function(){return zw(e)}}}},{kernelName:"Rsqrt",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return hk(kx(e,Nx(rN(n,1.5),2)))}}}},{kernelName:"Select",inputsToSave:["condition"],gradFunc:function(e,t){var n=t[0];return{condition:function(){return rb(zw(n),"float32")},t:function(){return Nx(e,rb(n,e.dtype))},e:function(){return Nx(e,rb(Rk(n),e.dtype))}}}},{kernelName:"Selu",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){var t=Jw(n,_N(0)),r=_N(1.7580993408473768),a=_N(fT),i=Nx(e,a),o=Nx(Nx(e,r),Uw(rb(n,"float32")));return Lw(t,i,o)}}}},{kernelName:"Sigmoid",outputsToSave:[!0],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(e,Nx(n,vk(_N(1),n)))}}}},{kernelName:"Sign",gradFunc:function(e){return{x:function(){return zw(e)}}}},{kernelName:ig,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(Iw(rb(n,"float32")),e)}}}},{kernelName:"Sinh",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(Sw(rb(n,"float32")),e)}}}},{kernelName:"Slice",inputsToSave:["x"],gradFunc:function(e,t,n){for(var r=t[0],a=n.begin,i=n.size,o=r.shape,s=$b(r,a,i),u=s[0],l=s[1],c=[],p=0;p<e.rank;p++)c.push([u[p],o[p]-u[p]-l[p]]);return{x:function(){return Jk(e,c)}}}},{kernelName:"Softmax",outputsToSave:[!0],gradFunc:function(e,t,n){var r=t[0],a=n.dim,i=Nx(e,r);return{logits:function(){return vk(i,Nx(gk(i,[a],!0),r))}}}},{kernelName:"Softplus",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(e,ew(n))}}}},BC,BC,WC,WC,{kernelName:"Sqrt",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return kx(e,Nx(ZN(rb(n,"float32")),2))}}}},{kernelName:"SquaredDifference",inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=_N(2);return{a:function(){return Nx(e,Nx(a,vk(n,r)))},b:function(){return Nx(e,Nx(a,vk(r,n)))}}}},{kernelName:"Square",inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(e,Nx(rb(n,"float32"),2))}}}},{kernelName:"Step",gradFunc:function(e){return{x:function(){return zw(e)}}}},{kernelName:og,inputsToSave:["a","b"],gradFunc:function(e,t){var n=t[0],r=t[1],a=Ow(n.shape,r.shape);return{a:function(){var t=e,r=_w(n.shape,a);return r.length>0&&(t=gk(t,r)),Jx(t,n.shape)},b:function(){var t=e,n=_w(r.shape,a);return n.length>0&&(t=gk(t,n)),Jx(hk(t),r.shape)}}}},{kernelName:"Sum",inputsToSave:["x"],gradFunc:function(e,t,n){var r=t[0],a=r.shape.slice();xv(n.axis,r.shape).forEach((function(e){a[e]=1}));var i=Jx(e,a),o=Nx(i,Kk(r.shape,"float32"));return{x:function(){return o}}}},{kernelName:sg,inputsToSave:["x"],gradFunc:function(e,t){var n=t[0];return{x:function(){return kx(e,Vk(Iw(n)))}}}},{kernelName:"Tanh",outputsToSave:[!0],gradFunc:function(e,t){var n=t[0];return{x:function(){return Nx(vk(_N(1),Vk(n)),e)}}}},VC,{kernelName:"Transpose",gradFunc:function(e,t,n){var r=Sk(n.perm);return{x:function(){return Tb(e,r)}}}},{kernelName:"Unpack",gradFunc:function(e,t,n){var r=n.axis;return{value:function(){return eI(e,r)}}}},{kernelName:"UnsortedSegmentSum",inputsToSave:["segmentIds"],gradFunc:function(e,t){var n=t[0];return{x:function(){return function(e,t){for(var n=Mk(t,zw(t)),r=Yw(e,n),a=Zw(t,_N(0,"int32")),i=r.rank-a.rank,o=0;o<i;++o)a=Gw(a,o+1);a=Ek(a,Kk(r.shape,"bool"));var s=zw(r);return Lw(a,r,s)}(e,n)}}}},{kernelName:"ZerosLike",gradFunc:function(e){return{x:function(){return zw(e)}}}}];GC<jC.length;GC++){dg(jC[GC])}function HC(){return null==UC&&(UC=bx().epsilon()),UC}Fg.prototype.abs=function(){return this.throwIfDisposed(),Ix(this)},Fg.prototype.acos=function(){return this.throwIfDisposed(),Sx(this)},Fg.prototype.acosh=function(){return this.throwIfDisposed(),Tx(this)},Fg.prototype.addStrict=function(e){return this.throwIfDisposed(),NI(this,e)},Fg.prototype.add=function(e){return this.throwIfDisposed(),xx(this,e)},Fg.prototype.all=function(e,t){return this.throwIfDisposed(),Ex(this,e,t)},Fg.prototype.any=function(e,t){return this.throwIfDisposed(),Rx(this,e,t)},Fg.prototype.argMax=function(e){return this.throwIfDisposed(),Ax(this,e)},Fg.prototype.argMin=function(e){return this.throwIfDisposed(),Dx(this,e)},Fg.prototype.asScalar=function(){return this.throwIfDisposed(),lv(1===this.size,(function(){return"The array must have only 1 element."})),Jx(this,[])},Fg.prototype.asType=function(e){return this.throwIfDisposed(),rb(this,e)},Fg.prototype.as1D=function(){return this.throwIfDisposed(),Jx(this,[this.size])},Fg.prototype.as2D=function(e,t){return this.throwIfDisposed(),Jx(this,[e,t])},Fg.prototype.as3D=function(e,t,n){return this.throwIfDisposed(),Jx(this,[e,t,n])},Fg.prototype.as4D=function(e,t,n,r){return this.throwIfDisposed(),Jx(this,[e,t,n,r])},Fg.prototype.as5D=function(e,t,n,r,a){return this.throwIfDisposed(),Jx(this,[e,t,n,r,a])},Fg.prototype.asin=function(){return this.throwIfDisposed(),Fx(this)},Fg.prototype.asinh=function(){return this.throwIfDisposed(),_x(this)},Fg.prototype.atan=function(){return this.throwIfDisposed(),Ox(this)},Fg.prototype.atan2=function(e){return this.throwIfDisposed(),Mx(this,e)},Fg.prototype.atanh=function(){return this.throwIfDisposed(),Lx(this)},Fg.prototype.avgPool=function(e,t,n,r){return this.throwIfDisposed(),Zx(this,e,t,n,r)},Fg.prototype.batchToSpaceND=function(e,t){return this.throwIfDisposed(),aw(this,e,t)},Fg.prototype.batchNorm=function(e,t,n,r,a){return this.throwIfDisposed(),iw(this,e,t,n,r,a)},Fg.prototype.broadcastTo=function(e){return this.throwIfDisposed(),cw(this,e)},Fg.prototype.cast=function(e){return this.throwIfDisposed(),rb(this,e)},Fg.prototype.ceil=function(){return this.throwIfDisposed(),pw(this)},Fg.prototype.clipByValue=function(e,t){return this.throwIfDisposed(),hw(this,e,t)},Fg.prototype.concat=function(e,t){return this.throwIfDisposed(),e instanceof Fg&&(e=[e]),$x([this].concat(e),t)},Fg.prototype.conv1d=function(e,t,n,r,a,i){return this.throwIfDisposed(),yw(this,e,t,n,r,a,i)},Fg.prototype.conv2dTranspose=function(e,t,n,r,a){return this.throwIfDisposed(),xw(this,e,t,n,r,a)},Fg.prototype.conv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),gw(this,e,t,n,r,a,i)},Fg.prototype.cos=function(){return this.throwIfDisposed(),Iw(this)},Fg.prototype.cosh=function(){return this.throwIfDisposed(),Sw(this)},Fg.prototype.cumsum=function(e,t,n){return this.throwIfDisposed(),Tw(this,e,t,n)},Fg.prototype.depthToSpace=function(e,t){return this.throwIfDisposed(),Ew(this,e,t)},Fg.prototype.depthwiseConv2D=function(e,t,n,r,a,i){return px("depthwiseConv2D is deprecated, use depthwiseConv2d instead"),this.throwIfDisposed(),Rw(this,e,t,n,r,a,i)},Fg.prototype.depthwiseConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),Rw(this,e,t,n,r,a,i)},Fg.prototype.dilation2d=function(e,t,n,r,a){return this.throwIfDisposed(),Dw(this,e,t,n,r,a)},Fg.prototype.divNoNan=function(e){return this.throwIfDisposed(),Pw(this,e)},Fg.prototype.divStrict=function(e){return this.throwIfDisposed(),II(this,e)},Fg.prototype.div=function(e){return this.throwIfDisposed(),kx(this,e)},Fg.prototype.dot=function(e){return this.throwIfDisposed(),Bw(this,e)},Fg.prototype.elu=function(){return this.throwIfDisposed(),Ww(this)},Fg.prototype.equalStrict=function(e){return this.throwIfDisposed(),gI(this,e)},Fg.prototype.equal=function(e){return this.throwIfDisposed(),Mw(this,e)},Fg.prototype.erf=function(){return this.throwIfDisposed(),Vw(this)},Fg.prototype.exp=function(){return this.throwIfDisposed(),Uw(this)},Fg.prototype.expandDims=function(e){return this.throwIfDisposed(),Gw(this,e)},Fg.prototype.expm1=function(){return this.throwIfDisposed(),jw(this)},Fg.prototype.fft=function(){return this.throwIfDisposed(),qN(this)},Fg.prototype.flatten=function(){return this.throwIfDisposed(),Jx(this,[this.size])},Fg.prototype.floor=function(){return this.throwIfDisposed(),Xw(this)},Fg.prototype.floorDiv=function(e){return this.throwIfDisposed(),wx(this,e)},Fg.prototype.gather=function(e,t){return this.throwIfDisposed(),Yw(this,e,t)},Fg.prototype.greaterEqualStrict=function(e){return this.throwIfDisposed(),yI(this,e)},Fg.prototype.greaterEqual=function(e){return this.throwIfDisposed(),Zw(this,e)},Fg.prototype.greaterStrict=function(e){return this.throwIfDisposed(),bI(this,e)},Fg.prototype.greater=function(e){return this.throwIfDisposed(),Jw(this,e)},Fg.prototype.ifft=function(){return this.throwIfDisposed(),KN(this)},Fg.prototype.irfft=function(){return this.throwIfDisposed(),XN(this)},Fg.prototype.isFinite=function(){return this.throwIfDisposed(),$w(this)},Fg.prototype.isInf=function(){return this.throwIfDisposed(),ek(this)},Fg.prototype.isNaN=function(){return this.throwIfDisposed(),tk(this)},Fg.prototype.leakyRelu=function(e){return this.throwIfDisposed(),nk(this,e)},Fg.prototype.lessEqualStrict=function(e){return this.throwIfDisposed(),xI(this,e)},Fg.prototype.lessEqual=function(e){return this.throwIfDisposed(),ak(this,e)},Fg.prototype.lessStrict=function(e){return this.throwIfDisposed(),wI(this,e)},Fg.prototype.less=function(e){return this.throwIfDisposed(),rk(this,e)},Fg.prototype.localResponseNormalization=function(e,t,n,r){return this.throwIfDisposed(),ok(this,e,t,n,r)},Fg.prototype.logSigmoid=function(){return this.throwIfDisposed(),dk(this)},Fg.prototype.logSoftmax=function(e){return this.throwIfDisposed(),yk(this,e)},Fg.prototype.logSumExp=function(e,t){return this.throwIfDisposed(),Ck(this,e,t)},Fg.prototype.log=function(){return this.throwIfDisposed(),sk(this)},Fg.prototype.log1p=function(){return this.throwIfDisposed(),uk(this)},Fg.prototype.logicalAnd=function(e){return this.throwIfDisposed(),Ek(this,e)},Fg.prototype.logicalNot=function(){return this.throwIfDisposed(),Rk(this)},Fg.prototype.logicalOr=function(e){return this.throwIfDisposed(),Ak(this,e)},Fg.prototype.logicalXor=function(e){return this.throwIfDisposed(),Dk(this,e)},Fg.prototype.matMul=function(e,t,n){return this.throwIfDisposed(),Ib(this,e,t,n)},Fg.prototype.maxPool=function(e,t,n,r){return this.throwIfDisposed(),Fk(this,e,t,n,r)},Fg.prototype.max=function(e,t){return this.throwIfDisposed(),mk(this,e,t)},Fg.prototype.maximumStrict=function(e){return this.throwIfDisposed(),SI(this,e)},Fg.prototype.maximum=function(e){return this.throwIfDisposed(),Mk(this,e)},Fg.prototype.mean=function(e,t){return this.throwIfDisposed(),Lk(this,e,t)},Fg.prototype.min=function(e,t){return this.throwIfDisposed(),zk(this,e,t)},Fg.prototype.minimumStrict=function(e){return this.throwIfDisposed(),TI(this,e)},Fg.prototype.minimum=function(e){return this.throwIfDisposed(),Pk(this,e)},Fg.prototype.mirrorPad=function(e,t){return this.throwIfDisposed(),Bk(this,e,t)},Fg.prototype.modStrict=function(e){return this.throwIfDisposed(),CI(this,e)},Fg.prototype.mod=function(e){return this.throwIfDisposed(),Wk(this,e)},Fg.prototype.mulStrict=function(e){return this.throwIfDisposed(),EI(this,e)},Fg.prototype.mul=function(e){return this.throwIfDisposed(),Nx(this,e)},Fg.prototype.neg=function(){return this.throwIfDisposed(),hk(this)},Fg.prototype.norm=function(e,t,n){return this.throwIfDisposed(),FI(this,e,t,n)},Fg.prototype.notEqualStrict=function(e){return this.throwIfDisposed(),kI(this,e)},Fg.prototype.notEqual=function(e){return this.throwIfDisposed(),Hk(this,e)},Fg.prototype.oneHot=function(e,t,n){return void 0===t&&(t=1),void 0===n&&(n=0),this.throwIfDisposed(),Sb(this,e,t,n)},Fg.prototype.onesLike=function(){return this.throwIfDisposed(),Xk(this)},Fg.prototype.pad=function(e,t){return this.throwIfDisposed(),Jk(this,e,t)},Fg.prototype.pool=function(e,t,n,r,a){return this.throwIfDisposed(),nN(this,e,t,n,r,a)},Fg.prototype.powStrict=function(e){return this.throwIfDisposed(),RI(this,e)},Fg.prototype.pow=function(e){return this.throwIfDisposed(),rN(this,e)},Fg.prototype.prelu=function(e){return this.throwIfDisposed(),aN(this,e)},Fg.prototype.prod=function(e,t){return this.throwIfDisposed(),iN(this,e,t)},Fg.prototype.reciprocal=function(){return this.throwIfDisposed(),NN(this)},Fg.prototype.relu=function(){return this.throwIfDisposed(),IN(this)},Fg.prototype.relu6=function(){return this.throwIfDisposed(),SN(this)},Fg.prototype.reshapeAs=function(e){return this.throwIfDisposed(),Jx(this,e.shape)},Fg.prototype.reshape=function(e){return this.throwIfDisposed(),Jx(this,e)},Fg.prototype.resizeBilinear=function(e,t,n){return this.throwIfDisposed(),SS(this,e,t,n)},Fg.prototype.resizeNearestNeighbor=function(e,t,n){return this.throwIfDisposed(),TS(this,e,t,n)},Fg.prototype.reverse=function(e){return this.throwIfDisposed(),TN(this,e)},Fg.prototype.rfft=function(){return this.throwIfDisposed(),JN(this)},Fg.prototype.round=function(){return this.throwIfDisposed(),DN(this)},Fg.prototype.rsqrt=function(){return this.throwIfDisposed(),FN(this)},Fg.prototype.selu=function(){return this.throwIfDisposed(),ON(this)},Fg.prototype.separableConv2d=function(e,t,n,r,a,i){return this.throwIfDisposed(),MN(this,e,t,n,r,a,i)},Fg.prototype.sigmoid=function(){return this.throwIfDisposed(),ew(this)},Fg.prototype.sign=function(){return this.throwIfDisposed(),PN(this)},Fg.prototype.sin=function(){return this.throwIfDisposed(),BN(this)},Fg.prototype.sinh=function(){return this.throwIfDisposed(),WN(this)},Fg.prototype.slice=function(e,t){return this.throwIfDisposed(),tw(this,e,t)},Fg.prototype.softmax=function(e){return this.throwIfDisposed(),HN(this,e)},Fg.prototype.softplus=function(){return this.throwIfDisposed(),fk(this)},Fg.prototype.spaceToBatchND=function(e,t){return this.throwIfDisposed(),tN(this,e,t)},Fg.prototype.split=function(e,t){return this.throwIfDisposed(),YN(this,e,t)},Fg.prototype.sqrt=function(){return this.throwIfDisposed(),ZN(this)},Fg.prototype.square=function(){return this.throwIfDisposed(),Vk(this)},Fg.prototype.squaredDifference=function(e){return this.throwIfDisposed(),QN(this,e)},Fg.prototype.squaredDifferenceStrict=function(e){return this.throwIfDisposed(),AI(this,e)},Fg.prototype.squeeze=function(e){return this.throwIfDisposed(),$N(this,e)},Fg.prototype.stack=function(e,t){this.throwIfDisposed();var n=e instanceof Fg?[this,e]:[this].concat(e);return eI(n,t)},Fg.prototype.step=function(e){return this.throwIfDisposed(),tI(this,e)},Fg.prototype.stridedSlice=function(e,t,n,r,a,i,o,s){return this.throwIfDisposed(),nI(this,e,t,n,r,a,i,o,s)},Fg.prototype.subStrict=function(e){return this.throwIfDisposed(),DI(this,e)},Fg.prototype.sub=function(e){return this.throwIfDisposed(),vk(this,e)},Fg.prototype.sum=function(e,t){return this.throwIfDisposed(),gk(this,e,t)},Fg.prototype.tan=function(){return this.throwIfDisposed(),rI(this)},Fg.prototype.tanh=function(){return this.throwIfDisposed(),nw(this)},Fg.prototype.tile=function(e){return this.throwIfDisposed(),Hw(this,e)},Fg.prototype.toBool=function(){return this.throwIfDisposed(),rb(this,"bool")},Fg.prototype.toFloat=function(){return this.throwIfDisposed(),rb(this,"float32")},Fg.prototype.toInt=function(){return this.throwIfDisposed(),rb(this,"int32")},Fg.prototype.topk=function(e,t){return this.throwIfDisposed(),oI(this,e,t)},Fg.prototype.transpose=function(e){return this.throwIfDisposed(),Tb(this,e)},Fg.prototype.unique=function(e){return this.throwIfDisposed(),uI(this,e)},Fg.prototype.unsortedSegmentSum=function(e,t){return this.throwIfDisposed(),lI(this,e,t)},Fg.prototype.unstack=function(e){return this.throwIfDisposed(),cI(this,e)},Fg.prototype.where=function(e,t){return this.throwIfDisposed(),Lw(e,this,t)},Fg.prototype.zerosLike=function(){return this.throwIfDisposed(),zw(this)};var qC=function(e){function t(n){var r;return r=e.call(this,n)||this,Object.setPrototypeOf(Qm(r),t.prototype),r}return qm(t,e),t}(Zm(Error)),KC=function(e){function t(n){var r;return r=e.call(this,n)||this,Object.setPrototypeOf(Qm(r),t.prototype),r}return qm(t,e),t}(Zm(Error)),XC=function(e){function t(n){var r;return r=e.call(this,n)||this,Object.setPrototypeOf(Qm(r),t.prototype),r}return qm(t,e),t}(Zm(Error)),YC=function(e){function t(n){var r;return r=e.call(this,n)||this,Object.setPrototypeOf(Qm(r),t.prototype),r}return qm(t,e),t}(Zm(Error)),JC=function(e){function t(n){var r;return r=e.call(this,n)||this,Object.setPrototypeOf(Qm(r),t.prototype),r}return qm(t,e),t}(Zm(Error));Error;function ZC(e,t){if(Array.isArray(e)){for(var n=[],r=0;r<t;r++)n=n.concat(e);return n}var a=new Array(t);return a.fill(e),a}function QC(e,t){if(!e)throw new JC(t)}function $C(e,t){for(var n,r=0,a=tv(e);!(n=a()).done;){n.value===t&&r++}return r}function eE(e){return 1===e.length?e[0]:e}function tE(e){return Array.isArray(e)?e:[e]}function nE(e){var t=e.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return"_"!==t[0]?t:"private"+t}function rE(e){return e.length<=1||-1===e.indexOf("_")?e:e.replace(/[_]+(\w|$)/g,(function(e,t){return t.toUpperCase()}))}var aE={};function iE(e){if(null==e)return null;var t={};return t.className=e.getClassName(),t.config=e.getConfig(),t}function oE(e,t,n,r,a){if(void 0===t&&(t={}),void 0===n&&(n={}),void 0===r&&(r="object"),void 0===a&&(a=!1),"string"==typeof e){var i,o=e;if(o in n)i=n[o];else if(o in aE)i=aE[o];else if(null==(i=t[o]))throw new XC("Unknown "+r+": "+e+". This may be due to one of the following reasons:\n1. The "+r+" is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom "+r+" is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().");return i}var s=e;if(null==s.className||null==s.config)throw new XC(r+": Improper config format: "+JSON.stringify(s)+".\n'className' and 'config' must set.");var u,l,c=s.className;if(c in n){var p=n[c];u=p[0],l=p[1]}else if(c in aE){var h=aE.className;u=h[0],l=h[1]}else if(c in t){var f=t[c];u=f[0],l=f[1]}if(null==u)throw new XC("Unknown "+r+": "+c+". This may be due to one of the following reasons:\n1. The "+r+" is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom "+r+" is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().");if(null!=l){for(var d={},m=0,v=Object.keys(aE);m<v.length;m++){var g=v[m];d[g]=aE[g]}for(var y=0,b=Object.keys(n);y<b.length;y++){var x=b[y];d[x]=n[x]}s.config.customObjects=d;for(var w=Object.assign({},aE),k=0,N=Object.keys(n);k<N.length;k++){var I=N[k];aE[I]=n[I]}!function e(t){if(null!=t&&"object"==typeof t)if(Array.isArray(t))t.forEach((function(t){return e(t)}));else for(var n=0,r=Object.keys(t);n<r.length;n++){var a=r[n],i=t[a];null!=i&&"object"==typeof i&&(Array.isArray(i)||"ndarray"!==i.type||"number"!=typeof i.value?e(i):t[a]=i.value)}}(s.config);var S=l(u,s.config,n,a);return aE=Object.assign({},w),S}for(var T=Object.assign({},aE),C=0,E=Object.keys(n);C<E.length;C++){var R=E[C];aE[R]=n[R]}var A=new u(s.config);return aE=Object.assign({},T),A}function sE(e,t){return-1*function(e,t){return e<t?-1:e>t?1:0}(e,t)}function uE(e){if(null==e)return e;for(var t,n=[],r=tv(e);!(t=r()).done;){var a=t.value;-1===n.indexOf(a)&&n.push(a)}return n}function lE(e){if(null==e)throw new XC("Invalid value in obj: "+JSON.stringify(e));for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}function cE(e,t,n){if(null!=n&&e.indexOf(n)<0)throw new XC(n+" is not a valid "+t+".  Valid values are "+e+" or null/undefined.")}function pE(e,t,n,r){return void 0===n&&(n=0),void 0===r&&(r=1/0),QC(n>=0),QC(r>=n),Array.isArray(e)&&e.length>=n&&e.length<=r&&e.every((function(e){return typeof e===t}))}function hE(e,t){Array.isArray(e)?(lv(e.length>0,(function(){return t+" is unexpectedly an empty array."})),e.forEach((function(e,n){return hE(e,"element "+(n+1)+" of "+t)}))):lv(Number.isInteger(e)&&e>0,(function(){return"Expected "+t+" to be a positive integer, but got "+function e(t){return null===t?"null":Array.isArray(t)?"["+t.map((function(t){return e(t)})).join(",")+"]":"string"==typeof t?'"'+t+'"':""+t}(e)+"."}))}function fE(e){return"relu"===e?"relu":"linear"===e?"linear":"elu"===e?"elu":null}function dE(e,t){return dx((function(){return ZN(gk(Nx(e,e),t,!0))}))}var mE=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.getConfig=function(){return{}},t}(nx),vE=function(e){function t(t){var n;return(n=e.call(this)||this).defaultMaxValue=2,n.defaultAxis=0,n.maxValue=null!=t.maxValue?t.maxValue:n.defaultMaxValue,n.axis=null!=t.axis?t.axis:n.defaultAxis,n}qm(t,e);var n=t.prototype;return n.apply=function(e){var t=this;return dx((function(){var n=dE(e,t.axis),r=hw(n,0,t.maxValue);return Nx(e,kx(r,xx(HC(),n)))}))},n.getConfig=function(){return{maxValue:this.maxValue,axis:this.axis}},t}(mE);vE.className="MaxNorm",ax(vE);var gE=function(e){function t(t){var n;return(n=e.call(this)||this).defaultAxis=0,n.axis=null!=t.axis?t.axis:n.defaultAxis,n}qm(t,e);var n=t.prototype;return n.apply=function(e){var t=this;return dx((function(){return kx(e,xx(HC(),dE(e,t.axis)))}))},n.getConfig=function(){return{axis:this.axis}},t}(mE);gE.className="UnitNorm",ax(gE);var yE=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e){return IN(e)},t}(mE);yE.className="NonNeg",ax(yE);var bE=function(e){function t(t){var n;return(n=e.call(this)||this).defaultMinValue=0,n.defaultMaxValue=1,n.defaultRate=1,n.defaultAxis=0,n.minValue=null!=t.minValue?t.minValue:n.defaultMinValue,n.maxValue=null!=t.maxValue?t.maxValue:n.defaultMaxValue,n.rate=null!=t.rate?t.rate:n.defaultRate,n.axis=null!=t.axis?t.axis:n.defaultAxis,n}qm(t,e);var n=t.prototype;return n.apply=function(e){var t=this;return dx((function(){var n=dE(e,t.axis),r=xx(Nx(t.rate,hw(n,t.minValue,t.maxValue)),Nx(1-t.rate,n));return Nx(e,kx(r,xx(HC(),n)))}))},n.getConfig=function(){return{minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis}},t}(mE);bE.className="MinMaxNorm",ax(bE);var xE={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function wE(e){return iE(e)}function kE(e,t){return void 0===t&&(t={}),oE(e,rx.getMap().classNameMap,t,"constraint")}function NE(e){return null==e?null:"string"==typeof e?kE({className:e in xE?xE[e]:e,config:{}}):e instanceof mE?e:kE(e)}var IE={__proto__:null,maxNorm:function(e){return new vE(e)},unitNorm:function(e){return new gE(e)},nonNeg:function(){return new yE},minMaxNorm:function(e){return new bE(e)}},SE=["channelsFirst","channelsLast"],TE=["nearest","bilinear"],CE=["valid","same","causal"],EE=["max","avg"],RE=["sum","mul","concat","ave"],AE=new Map;function DE(e){cE(SE,"DataFormat",e)}function FE(e){cE(CE,"PaddingMode",e)}function _E(e){cE(EE,"PoolMode",e)}var OE=[];function ME(e,t){OE.push(e);try{var n=t();return OE.pop(),n}catch(e){throw OE.pop(),e}}function LE(e){if(!BE(e))throw new Error("Not a valid tensor name: '"+e+"'");return(0===OE.length?"":OE.join("/")+"/")+e}function zE(e){if(!BE(e))throw new Error("Not a valid tensor name: '"+e+"'");AE.has(e)||AE.set(e,0);var t=AE.get(e);if(AE.set(e,AE.get(e)+1),t>0){var n=e+"_"+t;return AE.set(n,1),n}return e}var PE=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function BE(e){return!!e.match(PE)}function WE(e,t,n){null==t&&(t=0),null==n&&(n=e.length);for(var r=1,a=t;a<n;++a)r*=e[a];return r}function VE(e){return aI(e=Array.isArray(e)?new Float32Array(e):e)}function UE(e){return zk(VE(e)).dataSync()[0]}function GE(e){return mk(VE(e)).dataSync()[0]}function jE(e,t){if(t<e)throw new XC("end ("+t+") < begin ("+e+") is forbidden.");for(var n=[],r=e;r<t;++r)n.push(r);return n}function HE(e,t){return e.asType(t)}function qE(e,t){void 0===t&&(t=-1);var n=e.shape.slice();return t<0&&(t=n.length+t+1),n.splice(t,0,1),e.reshape(n)}function KE(e,t,n){return dx((function(){switch(e.rank){case 1:return VN(e,t,n);case 2:return UN(e,[t,0],[n,e.shape[1]]);case 3:return GN(e,[t,0,0],[n,e.shape[1],e.shape[2]]);case 4:return jN(e,[t,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3]]);case 5:return tw(e,[t,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4]]);case 6:return tw(e,[t,0,0,0,0,0],[n,e.shape[1],e.shape[2],e.shape[3],e.shape[4],e.shape[5]]);default:throw new XC("sliceAlongFirstAxis() received an unsupported tensor rank: "+e.rank)}}))}function XE(e,t,n){return dx((function(){switch(e.rank){case 1:return VN(e,t,n);case 2:return UN(e,[0,t],[e.shape[0],n]);case 3:return GN(e,[0,0,t],[e.shape[0],e.shape[1],n]);case 4:return jN(e,[0,0,0,t],[e.shape[0],e.shape[1],e.shape[2],n]);default:throw new XC("sliceAlongLastAxis() received an unsupported tensor rank: "+e.rank)}}))}function YE(e,t,n,r){return dx((function(){switch(e.rank){case 1:return VN(e,t,n);case 2:switch(r){case 1:return KE(e,t,n);case 2:return XE(e,t,n);default:throw new XC("The axis is not within the rank of the tensor "+r)}case 3:switch(r){case 1:return KE(e,t,n);case 2:return GN(e,[0,t,0],[e.shape[0],n,e.shape[2]]);case 3:return XE(e,t,n);default:throw new XC("The axis is not within the rank of the tensor "+r)}case 4:switch(r){case 1:return KE(e,t,n);case 2:return jN(e,[0,t,0,0],[e.shape[0],n,e.shape[2],e.shape[3]]);case 3:return jN(e,[0,0,t,0],[e.shape[0],e.shape[1],n,e.shape[3]]);case 4:return XE(e,t,n);default:throw new XC("The axis is not within the rank of the tensor "+r)}default:throw new XC("sliceAlongLastAxis() received an unsupported tensor rank: "+e.rank)}}))}function JE(e,t){var n;return void 0===t&&(t=-1),t<0&&(t=0!==(n=e[0].rank)?n:0),t===e[0].rank&&(t=-1),$x(e,t)}function ZE(e,t){switch(e.rank){case 1:return fw([e,t]);case 2:return dw([e,t],0);case 3:return mw([e,t],0);case 4:return vw([e,t],0);default:throw new XC("concatAlongFirstAxis() received an unsupported tensor rank: "+e.rank)}}function QE(e,t){if(Array.isArray(t)||(t=[t]),e.rank!==t.length)throw new XC("The length of input n ("+t.length+") does not match the number of dimensions in input x ("+e.rank+")");return Hw(e,t)}function $E(e,t,n,r,a){return void 0===t&&(t=0),void 0===n&&(n=1),bN(e,t,n,r,a)}function eR(e,t,n,r){if(e.rank<2||t.rank<2)throw new YC("dot requires both inputs to be rank >= 2 but got x shape = "+e.shape+" and y shape = "+t.shape);if(t.rank>=3&&e.shape.slice(-1)[0]!==t.shape.slice(-2)[0])throw new YC("If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = "+e.shape+" and  y shape = "+t.shape);if(2===e.rank&&2===t.rank){return ZI({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?rR(e.rank,r,"channelsLast"):null,activation:n})}var a=e.shape.slice(),i=a.pop();e=e.reshape([-1,i]);var o=t.shape.slice(),s=o.pop(),u=o.pop(),l=[].concat(o,[s]),c=Array.from({length:t.rank},(function(e,n){return 0===n?t.rank-2:n<=t.rank-2?n-1:n}));t=t.transpose(c).reshape([u,-1]);var p=[].concat(a,l);return ZI({a:e,b:t,transposeA:!1,transposeB:!1,bias:r?rR(e.rank,r,"channelsLast"):null,activation:n}).reshape(p)}function tR(e,t,n){return dx((function(){return t=Array.isArray(t)?aI(t,"int32"):t.toInt(),Yw(e,t,n)}))}function nR(e){return Nx(e,e)}function rR(e,t,n){var r=t.shape;if(1!==t.rank&&t.rank!==e)throw new XC("Unexpected bias dimensions: "+t.rank+"; expected it to be 1 or "+e);if(5===e){if("channelsFirst"===n)return 1===r.length?t.reshape([1,r[0],1,1,1]):t.reshape([1,r[3],r[0],r[1],r[2]]);if("channelsLast"===n)return 1===r.length?t.reshape([1,1,1,1,r[0]]):t.reshape([1].concat(r))}else if(4===e){if("channelsFirst"===n)return 1===r.length?t.reshape([1,r[0],1,1]):t.reshape([1,r[2],r[0],r[1]]);if("channelsLast"===n)return 1===r.length?t.reshape([1,1,1,r[0]]):t.reshape([1].concat(r))}else if(3===e){if("channelsFirst"===n)return 1===r.length?t.reshape([1,r[0],1]):t.reshape([1,r[1],r[0]]);if("channelsLast"===n)return 1===r.length?t.reshape([1,1,r[0]]):t.reshape([1].concat(r))}else if(e<3)return t;throw new XC("Unsupported input rank by biasAdd: "+t.rank)}function aR(e,t,n){return dx((function(){return null==n&&(n="channelsLast"),DE(n),e.add(rR(e.rank,t,n))}))}function iR(e,t,n,r){return dx((function(){return zI(e,t,n,r)}))}function oR(e,t,n){return void 0===n&&(n=!1),n?e():t()}var sR=["fanIn","fanOut","fanAvg"],uR=["normal","uniform","truncatedNormal"];var lR=function(e){function t(){return e.apply(this,arguments)||this}qm(t,e);var n=t.prototype;return n.fromConfigUsesCustomObjects=function(){return!1},n.getConfig=function(){return{}},t}(nx),cR=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e,t){return qk(e,t)},t}(lR);cR.className="Zeros",ax(cR);var pR=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e,t){return Kk(e,t)},t}(lR);pR.className="Ones",ax(pR);var hR=function(e){function t(t){var n;if(n=e.call(this)||this,"object"!=typeof t)throw new XC("Expected argument of type ConstantConfig but got "+t);if(void 0===t.value)throw new XC("config must have value set but got "+t);return n.value=t.value,n}qm(t,e);var n=t.prototype;return n.apply=function(e,t){var n=this;return dx((function(){return Nx(_N(n.value),Kk(e,t))}))},n.getConfig=function(){return{value:this.value}},t}(lR);hR.className="Constant",ax(hR);var fR=function(e){function t(t){var n;return(n=e.call(this)||this).DEFAULT_MINVAL=-.05,n.DEFAULT_MAXVAL=.05,n.minval=t.minval||n.DEFAULT_MINVAL,n.maxval=t.maxval||n.DEFAULT_MAXVAL,n.seed=t.seed,n}qm(t,e);var n=t.prototype;return n.apply=function(e,t){return xN(e,this.minval,this.maxval,t)},n.getConfig=function(){return{minval:this.minval,maxval:this.maxval,seed:this.seed}},t}(lR);fR.className="RandomUniform",ax(fR);var dR=function(e){function t(t){var n;return(n=e.call(this)||this).DEFAULT_MEAN=0,n.DEFAULT_STDDEV=.05,n.mean=t.mean||n.DEFAULT_MEAN,n.stddev=t.stddev||n.DEFAULT_STDDEV,n.seed=t.seed,n}qm(t,e);var n=t.prototype;return n.apply=function(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new YC("randomNormal does not support dType "+t+".");return $E(e,this.mean,this.stddev,t,this.seed)},n.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},t}(lR);dR.className="RandomNormal",ax(dR);var mR=function(e){function t(t){var n;return(n=e.call(this)||this).DEFAULT_MEAN=0,n.DEFAULT_STDDEV=.05,n.mean=t.mean||n.DEFAULT_MEAN,n.stddev=t.stddev||n.DEFAULT_STDDEV,n.seed=t.seed,n}qm(t,e);var n=t.prototype;return n.apply=function(e,t){if("float32"!==(t=t||"float32")&&"int32"!==t)throw new YC("truncatedNormal does not support dType "+t+".");return sI(e,this.mean,this.stddev,t,this.seed)},n.getConfig=function(){return{mean:this.mean,stddev:this.stddev,seed:this.seed}},t}(lR);mR.className="TruncatedNormal",ax(mR);var vR=function(e){function t(t){var n;return(n=e.call(this)||this).gain=null!=t.gain?t.gain:1,n}qm(t,e);var n=t.prototype;return n.apply=function(e,t){var n=this;return dx((function(){if(2!==e.length||e[0]!==e[1])throw new XC("Identity matrix initializer can only be used for 2D square matrices.");return Nx(n.gain,qw(e[0]))}))},n.getConfig=function(){return{gain:this.gain}},t}(lR);vR.className="Identity",ax(vR);var gR=function(e){function t(t){var n,r;if(n=e.call(this)||this,t.scale<0)throw new XC("scale must be a positive float. Got: "+t.scale);return n.scale=null==t.scale?1:t.scale,n.mode=null==t.mode?"fanIn":t.mode,r=n.mode,cE(sR,"FanMode",r),n.distribution=null==t.distribution?"normal":t.distribution,function(e){cE(uR,"Distribution",e)}(n.distribution),n.seed=t.seed,n}qm(t,e);var n=t.prototype;return n.apply=function(e,t){var n=function(e,t){var n,r;if(void 0===t&&(t="channelsLast"),DE(t),2===e.length)n=e[0],r=e[1];else if(-1!==[3,4,5].indexOf(e.length)){if("channelsFirst"===t){var a=WE(e,2);n=e[1]*a,r=e[0]*a}else if("channelsLast"===t){var i=WE(e,0,e.length-2);n=e[e.length-2]*i,r=e[e.length-1]*i}}else{var o=WE(e);n=Math.sqrt(o),r=Math.sqrt(o)}return[n,r]}(e),r=n[0],a=n[1],i=this.scale;if("fanIn"===this.mode?i/=Math.max(1,r):"fanOut"===this.mode?i/=Math.max(1,a):i/=Math.max(1,(r+a)/2),"normal"===this.distribution){var o=Math.sqrt(i);if("float32"!==(t=t||"float32")&&"int32"!==t)throw new YC(this.getClassName()+" does not support dType "+t+".");return sI(e,0,o,t,this.seed)}var s=Math.sqrt(3*i);return xN(e,-s,s,t)},n.getConfig=function(){return{scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed}},t}(lR);gR.className="VarianceScaling",ax(gR);var yR=function(e){function t(t){return e.call(this,{scale:1,mode:"fanAvg",distribution:"uniform",seed:null==t?null:t.seed})||this}return qm(t,e),t.prototype.getClassName=function(){return gR.className},t}(gR);yR.className="GlorotUniform",ax(yR);var bR=function(e){function t(t){return e.call(this,{scale:1,mode:"fanAvg",distribution:"normal",seed:null==t?null:t.seed})||this}return qm(t,e),t.prototype.getClassName=function(){return gR.className},t}(gR);bR.className="GlorotNormal",ax(bR);var xR=function(e){function t(t){return e.call(this,{scale:2,mode:"fanIn",distribution:"normal",seed:null==t?null:t.seed})||this}return qm(t,e),t.prototype.getClassName=function(){return gR.className},t}(gR);xR.className="HeNormal",ax(xR);var wR=function(e){function t(t){return e.call(this,{scale:2,mode:"fanIn",distribution:"uniform",seed:null==t?null:t.seed})||this}return qm(t,e),t.prototype.getClassName=function(){return gR.className},t}(gR);wR.className="HeUniform",ax(wR);var kR=function(e){function t(t){return e.call(this,{scale:1,mode:"fanIn",distribution:"normal",seed:null==t?null:t.seed})||this}return qm(t,e),t.prototype.getClassName=function(){return gR.className},t}(gR);kR.className="LeCunNormal",ax(kR);var NR=function(e){function t(t){return e.call(this,{scale:1,mode:"fanIn",distribution:"uniform",seed:null==t?null:t.seed})||this}return qm(t,e),t.prototype.getClassName=function(){return gR.className},t}(gR);NR.className="LeCunNormal",ax(NR);var IR=function(e){function t(t){var n;if((n=e.call(this)||this).DEFAULT_GAIN=1,n.gain=null==t.gain?n.DEFAULT_GAIN:t.gain,n.seed=t.seed,null!=n.seed)throw new YC("Random seed is not implemented for Orthogonal Initializer yet.");return n}qm(t,e);var n=t.prototype;return n.apply=function(e,t){var n=this;return dx((function(){if(e.length<2)throw new YC("Shape must be at least 2D.");e[0]*e[1]>2e3&&console.warn("Orthogonal initializer is being called on a matrix with more than 2000 ("+e[0]*e[1]+") elements: Slowness may result.");var t=$E(e[0]>e[1]?[e[1],e[0]]:e,0,1,"float32"),r=jS.gramSchmidt(t);return e[0]>e[1]&&(r=r.transpose()),Nx(n.gain,r)}))},n.getConfig=function(){return{gain:this.gain,seed:this.seed}},t}(lR);IR.className="Orthogonal",ax(IR);var SR={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function TR(e,t){return void 0===t&&(t={}),oE(e,rx.getMap().classNameMap,t,"initializer")}function CR(e){return iE(e)}function ER(e){if("string"==typeof e){var t=e in SR?SR[e]:e;if("GlorotNormal"===t)return new bR;if("GlorotUniform"===t)return new yR;if("HeNormal"===t)return new xR;if("HeUniform"===t)return new wR;if("LeCunNormal"===t)return new kR;if("LeCunUniform"===t)return new NR;var n={};return n.className=t,n.config={},TR(n)}return e instanceof lR?e:TR(e)}var RR={__proto__:null,zeros:function(){return new cR},ones:function(){return new pR},constant:function(e){return new hR(e)},randomUniform:function(e){return new fR(e)},randomNormal:function(e){return new dR(e)},truncatedNormal:function(e){return new mR(e)},identity:function(e){return new vR(e)},varianceScaling:function(e){return new gR(e)},glorotUniform:function(e){return new yR(e)},glorotNormal:function(e){return new bR(e)},heNormal:function(e){return new xR(e)},heUniform:function(e){return new wR(e)},leCunNormal:function(e){return new kR(e)},leCunUniform:function(e){return new NR(e)},orthogonal:function(e){return new IR(e)}},AR=0;function DR(){return AR++}var FR={};function _R(e){return void 0===e&&(e=""),e in FR||(FR[e]=0),FR[e]+=1,e+FR[e].toString()}function OR(e){return Array.isArray(e)&&Array.isArray(e[0])}function MR(e){return 0===e.length?[]:Array.isArray(e[0])?e:[e]}function LR(e){var t;if(Array.isArray(e)){if(1!==e.length)throw new XC("Expected Tensor length to be 1; got "+e.length);t=e[0]}else t=e;return t}function zR(e){if(Array.isArray(e)&&Array.isArray(e[0])){if(1===e.length)return(e=e)[0];throw new XC("Expected exactly 1 Shape; got "+e.length)}return e}function PR(e){for(var t,n=0,r=tv(e);!(t=r()).done;){var a=t.value;0===a.shape.length?n+=1:n+=a.shape.reduce((function(e,t){return e*t}))}return n}var BR=function(){function e(e,t,n,r,a){void 0===t&&(t="float32"),void 0===n&&(n="Variable"),void 0===r&&(r=!0),void 0===a&&(a=null),this.dtype=null==t?"float32":t,this.shape=e.shape,this.id=DR(),n=null==n?"Variable":n,this.originalName=LE(n),this.name=zE(this.originalName),this.trainable_=r,this.constraint=a,this.val=pI(e,this.trainable_,this.name,this.dtype)}var t=e.prototype;return t.read=function(){return this.assertNotDisposed(),this.val},t.write=function(e){return this.assertNotDisposed(),function(e,t){if(e.shape.toString()!==t.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(e.shape)+" vs. "+JSON.stringify(t.shape))}(this.val,e),this.val.id!==e.id&&(this.val.assign(e),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this},t.dispose=function(){this.assertNotDisposed(),this.val.dispose()},t.assertNotDisposed=function(){if(this.val.isDisposed)throw new Error("LayersVariable "+this.name+" is already disposed.")},Hm(e,[{key:"trainable",get:function(){return this.trainable_},set:function(e){this.trainable_=e,this.val.trainable=e}}]),e}();function WR(e){return e.map((function(e){return e.read()}))}function VR(e){e.forEach((function(e){e[0].write(e[1])}))}var UR=function(e){this.dtype=e.dtype,this.shape=e.shape,null!=e.shape?this.ndim=e.shape.length:this.ndim=e.ndim,this.maxNDim=e.maxNDim,this.minNDim=e.minNDim,this.axes=e.axes||{}},GR=function(e,t,n,r,a,i,o){this.dtype=e,this.shape=t,this.sourceLayer=n,this.inputs=r,this.callArgs=a,this.outputTensorIndex=o,this.id=DR(),null!=i&&(this.originalName=LE(i),this.name=zE(this.originalName)),this.rank=t.length},jR=0,HR=function(){function e(e,t){this.callArgs=t,this.id=jR++,this.outboundLayer=e.outboundLayer,this.inboundLayers=e.inboundLayers,this.nodeIndices=e.nodeIndices,this.tensorIndices=e.tensorIndices,this.inputTensors=e.inputTensors,this.outputTensors=e.outputTensors,this.inputMasks=e.inputMasks,this.outputMasks=e.outputMasks,this.inputShapes=e.inputShapes,this.outputShapes=e.outputShapes;for(var n,r=tv(e.inboundLayers);!(n=r()).done;){var a=n.value;null!=a&&a.outboundNodes.push(this)}e.outboundLayer.inboundNodes.push(this)}return e.prototype.getConfig=function(){for(var e,t=[],n=tv(this.inboundLayers);!(e=n()).done;){var r=e.value;null!=r?t.push(r.name):t.push(null)}return{outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:t,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices}},e}(),qR=0,KR=function(e){function t(t){var n;void 0===t&&(t={}),(n=e.call(this)||this)._callHook=null,n._addedWeightNames=[],n._stateful=!1,n.id=qR++,n.activityRegularizer=null,n.inputSpec=null,n.supportsMasking=!1,n._trainableWeights=[],n._nonTrainableWeights=[],n._losses=[],n._updates=[],n._built=!1,n.inboundNodes=[],n.outboundNodes=[];var r=t.name;if(!r){var a=n.getClassName();r=nE(a)+"_"+_R(a)}if(n.name=r,n.trainable_=null==t.trainable||t.trainable,null!=t.inputShape||null!=t.batchInputShape){var i;if(null!=t.batchInputShape)i=t.batchInputShape;else if(null!=t.inputShape){var o=null;null!=t.batchSize&&(o=t.batchSize),i=[o].concat(t.inputShape)}n.batchInputShape=i;var s=t.dtype;null==s&&(s=t.inputDType),null==s&&(s="float32"),n.dtype=s}return null!=t.weights?n.initialWeights=t.weights:n.initialWeights=null,n._refCount=null,n.fastWeightInitDuringBuild=!1,n}qm(t,e),t.nodeKey=function(e,t){return e.name+"_ib-"+t.toString()};var n=t.prototype;return n.getNodeAtIndex=function(e,t){if(0===this.inboundNodes.length)throw new KC("The layer has never been called and thus has no defined "+t+".");if(this.inboundNodes.length<=e)throw new XC("Asked to get "+t+" at node "+e+", but the layer has only "+this.inboundNodes.length+" inbound nodes.");return this.inboundNodes[e]},n.getInputAt=function(e){return eE(this.getNodeAtIndex(e,"input").inputTensors)},n.getOutputAt=function(e){return eE(this.getNodeAtIndex(e,"output").outputTensors)},n.calculateLosses=function(){return this.losses.map((function(e){return e()}))},n.resetStates=function(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.")},n.assertInputCompatibility=function(e){if(e=tE(e),null!=this.inputSpec&&0!==this.inputSpec.length){var t=tE(this.inputSpec);if(e.length!==t.length)throw new XC("Layer "+this.name+" expects "+t.length+" inputs, but it received "+e.length+" input tensors. Input received: "+e);for(var n=0;n<e.length;n++){var r=e[n],a=t[n];if(null!=a){var i=r.rank;if(null!=a.ndim&&i!==a.ndim)throw new XC("Input "+n+" is incompatible with layer "+this.name+": expected ndim="+a.ndim+", found ndim="+i);if(null!=a.maxNDim&&i>a.maxNDim)throw new XC("Input "+n+" is incompatible with layer "+this.name+": expected max_ndim="+a.maxNDim+", found ndim="+i);if(null!=a.minNDim&&i<a.minNDim)throw new XC("Input "+n+" is incompatible with layer "+this.name+": expected min_ndim="+a.minNDim+", found ndim="+i+".");if(null!=a.dtype&&r.dtype!==a.dtype)throw new XC("Input "+n+" is incompatible with layer "+this.name+" : expected dtype="+a.dtype+", found dtype="+r.dtype+".");if(a.axes){var o=r.shape;for(var s in a.axes){var u=Number(s),l=a.axes[s],c=u>=0?o[u]:o[o.length+u];if(null!=l&&-1===[l,null].indexOf(c))throw new XC("Input "+n+" is incompatible with layer "+this.name+": expected axis "+u+" of input shape to have value "+l+" but got shape "+o+".")}}if(null!=a.shape)for(var p=0;p<a.shape.length;++p){var h=a.shape[p],f=r.shape[p];if(null!=h&&null!=f&&h!==f)throw new XC("Input "+n+" is incompatible with layer "+this.name+": expected shape="+a.shape+", found shape="+r.shape+".")}}}}},n.call=function(e,t){return e},n.invokeCallHook=function(e,t){null!=this._callHook&&this._callHook(e,t)},n.setCallHook=function(e){this._callHook=e},n.clearCallHook=function(){this._callHook=null},n.apply=function(e,t){var n=this;t=t||{},this.assertNotDisposed();for(var r,a=tE(e),i=!0,o=tv(a);!(r=o()).done;){if(!(r.value instanceof GR)){i=!1;break}}for(var s,u=!0,l=tv(a);!(s=l()).done;){if(s.value instanceof GR){u=!1;break}}if(i===u)throw new XC("Arguments to apply() must be all SymbolicTensors or all Tensors");return ME(this.name,(function(){if(!n.built){n.assertInputCompatibility(e);for(var r,i=[],o=tv(tE(e));!(r=o()).done;){var s=r.value;i.push(s.shape)}n.build(eE(i)),n.built=!0,n.initialWeights&&n.setWeights(n.initialWeights),null===n._refCount&&u&&(n._refCount=1)}if(n.assertInputCompatibility(e),u){for(var l,c=n.call(e,t),p=[],h=tv(tE(c));!(l=h()).done;){var f=l.value;-1!==a.indexOf(f)&&(f=f.clone()),p.push(f)}if(c=eE(p),null!=n.activityRegularizer)throw new YC("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return c}var d,m=function(e){e=tE(e);for(var t,n=[],r=tv(e);!(t=r()).done;){var a=t.value;n.push(a.shape)}return eE(n)}(e),v=n.computeOutputShape(m);if(n.warnOnIncompatibleInputShape(Array.isArray(e)?m[0]:m),d=null!=v&&v.length>0&&Array.isArray(v[0])?v.map((function(r,a){return new GR("float32",r,n,tE(e),t,n.name,a)})):new GR("float32",v,n,tE(e),t,n.name),n.addInboundNode(e,d,null,null,m,v,t),n._refCount++,null!=n.activityRegularizer)throw new YC("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return d}))},n.warnOnIncompatibleInputShape=function(e){if(null!=this.batchInputShape)if(e.length!==this.batchInputShape.length)console.warn("The rank of the input tensor provided (shape: "+JSON.stringify(e)+") does not match that of the batchInputShape ("+JSON.stringify(this.batchInputShape)+") of the layer "+this.name);else{var t=!1;this.batchInputShape.forEach((function(n,r){null!=n&&null!=e[r]&&e[r]!==n&&(t=!0)})),t&&console.warn("The shape of the input tensor ("+JSON.stringify(e)+") does not match the expectation of layer "+this.name+": "+JSON.stringify(this.batchInputShape))}},n.countParams=function(){if(!this.built)throw new KC("You tried to call countParams() on "+this.name+", but the layer is not built yet. Build it first by calling build(batchInputShape).");return PR(this.weights)},n.build=function(e){this.built=!0},n.getWeights=function(e){return void 0===e&&(e=!1),WR(e?this.trainableWeights:this.weights)},n.setWeights=function(e){var t=this;dx((function(){var n=t.weights;if(n.length!==e.length)throw new XC('You called setWeights(weights) on layer "'+t.name+'" with a weight list of length '+e.length+", but the layer was expecting "+n.length+" weights. Provided weights: "+e+"...");if(0!==n.length){for(var r=[],a=WR(n),i=0;i<a.length;++i){var o=a[i],s=n[i],u=e[i];if(!dv(o.shape,u.shape))throw new XC("Layer weight shape "+o.shape+" not compatible with provided weight shape "+u.shape);r.push([s,u])}VR(r)}}))},n.addWeight=function(e,t,n,r,a,i,o){if(-1!==this._addedWeightNames.indexOf(e))throw new XC("Duplicate weight name "+e+" for layer "+this.name);this._addedWeightNames.push(e),null==n&&(n="float32"),this.fastWeightInitDuringBuild&&(r=ER("zeros"));var s=r.apply(t,n),u=new BR(s,n,e,i,o);return s.dispose(),null!=a&&this.addLoss((function(){return a.apply(u.read())})),null==i&&(i=!0),i?this._trainableWeights.push(u):this._nonTrainableWeights.push(u),u},n.setFastWeightInitDuringBuild=function(e){this.fastWeightInitDuringBuild=e},n.addLoss=function(e){var t;null==e||Array.isArray(e)&&0===e.length||(e=tE(e),void 0!==this._losses&&null!==this._losses&&(t=this.losses).push.apply(t,e))},n.computeOutputShape=function(e){return e},n.computeMask=function(e,t){var n=this;if(!this.supportsMasking){if(null!=t){if(!Array.isArray(t))throw new TypeError("Layer "+this.name+" does not support masking, but was passed an inputMask.");t.forEach((function(e){if(null!=e)throw new TypeError("Layer "+n.name+" does not support masking, but was passed an inputMask.")}))}return null}return t},n.addInboundNode=function(e,t,n,r,a,i,o){void 0===o&&(o=null);var s=tE(e);t=tE(t),n=tE(n),r=tE(r),a=MR(a),i=MR(i);for(var u,l=[],c=[],p=[],h=tv(s);!(u=h()).done;){var f=u.value;l.push(f.sourceLayer),c.push(f.nodeIndex),p.push(f.tensorIndex)}new HR({outboundLayer:this,inboundLayers:l,nodeIndices:c,tensorIndices:p,inputTensors:s,outputTensors:t,inputMasks:n,outputMasks:r,inputShapes:a,outputShapes:i},o);for(var d=0;d<t.length;d++)t[d].sourceLayer=this,t[d].nodeIndex=this.inboundNodes.length-1,t[d].tensorIndex=d},n.getConfig=function(){var e={name:this.name,trainable:this.trainable};return null!=this.batchInputShape&&(e.batchInputShape=this.batchInputShape),null!=this.dtype&&(e.dtype=this.dtype),e},n.disposeWeights=function(){return this.weights.forEach((function(e){return e.dispose()})),this.weights.length},n.assertNotDisposed=function(){if(0===this._refCount)throw new Error("Layer '"+this.name+"' is already disposed.")},n.dispose=function(){if(!this.built)throw new Error("Cannot dispose Layer "+this.name+" because it has not been built yet.");if(null===this._refCount)throw new Error("Cannot dispose Layer "+this.name+" because it has not been used yet.");this.assertNotDisposed();var e=0;return 0==--this._refCount&&(e=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:e}},Hm(t,[{key:"input",get:function(){if(this.inboundNodes.length>1)throw new qC("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use `getInputAt(nodeIndex)` instead.');if(0===this.inboundNodes.length)throw new qC("Layer "+this.name+" is not connected, no input to return.");return eE(this.getNodeAtIndex(0,"input").inputTensors)}},{key:"output",get:function(){if(0===this.inboundNodes.length)throw new qC("Layer "+this.name+" has no inbound nodes.");if(this.inboundNodes.length>1)throw new qC("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');return eE(this.getNodeAtIndex(0,"output").outputTensors)}},{key:"losses",get:function(){return this._losses}},{key:"updates",get:function(){return this._updates}},{key:"built",get:function(){return this._built},set:function(e){this._built=e}},{key:"trainable",get:function(){return this.trainable_},set:function(e){this._trainableWeights.forEach((function(t){return t.trainable=e})),this.trainable_=e}},{key:"trainableWeights",get:function(){return this.trainable_?this._trainableWeights.filter((function(e){return e.trainable})):[]},set:function(e){this._trainableWeights=e}},{key:"nonTrainableWeights",get:function(){return this.trainable?this._trainableWeights.filter((function(e){return!e.trainable})).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights)},set:function(e){this._nonTrainableWeights=e}},{key:"weights",get:function(){return this.trainableWeights.concat(this.nonTrainableWeights)}},{key:"stateful",get:function(){return this._stateful}},{key:"outputShape",get:function(){if(null==this.inboundNodes||0===this.inboundNodes.length)throw new qC("The layer "+this.name+" has never been called and thus has no defined output shape.");for(var e,t=[],n=tv(this.inboundNodes);!(e=n()).done;){var r=e.value,a=JSON.stringify(r.outputShapes);-1===t.indexOf(a)&&t.push(a)}if(1===t.length){var i=this.inboundNodes[0].outputShapes;return Array.isArray(i)&&Array.isArray(i[0])&&1===i.length?i[0]:i}throw new qC("The layer "+this.name+' has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.')}}]),t}(nx);var XR,YR=function(e){function t(t){var n;if(n=e.call(this,{dtype:t.dtype,name:null!=t.name?t.name:_R("input").toString()})||this,null==t.batchSize&&(t.batchSize=null),null==t.sparse&&(t.sparse=!1),n.trainable=!1,n.built=!0,n.sparse=t.sparse,null!=t.inputShape&&null!=t.batchInputShape)throw new XC("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");var r=t.batchInputShape;if(null==r){if(null==t.inputShape)throw new XC("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");r=[t.batchSize].concat(t.inputShape)}else if(null!=t.batchSize)throw new XC("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");var a=t.dtype||"float32";n.batchInputShape=r,n.dtype=a,n.inputSpec=[{shape:r}];var i=new GR(n.dtype,n.batchInputShape,Qm(n),[],{},n.name);return i.nodeIndex=0,i.tensorIndex=0,new HR({outboundLayer:Qm(n),inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[i],outputTensors:[i],inputMasks:[null],outputMasks:[null],inputShapes:[r],outputShapes:[r]}),n}qm(t,e);var n=t.prototype;return n.apply=function(e,t){throw new XC("Cannot pass any input to an InputLayer's apply() method. InputLayer name: "+this.name)},n.dispose=function(){return{refCountAfterDispose:this._refCount,numDisposedVariables:0}},n.getConfig=function(){return{batchInputShape:this.batchInputShape,dtype:this.dtype,sparse:this.sparse,name:this.name}},t}(KR);function JR(e){if(null==e.batchShape&&null==e.shape)throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");if(null!=e.batchShape&&null!=e.shape)throw new XC("Please provide either a `shape` or `batchShape` argument to Input, but not both.");var t=e.batchShape;null!=e.shape&&null==t&&(t=[null].concat(e.shape));var n=e.dtype;return null==n&&(n="float32"),new YR({batchInputShape:t,name:e.name,dtype:n,sparse:e.sparse}).inboundNodes[0].outputTensors[0]}function ZR(e){return QR.apply(this,arguments)}function QR(){return(QR=Gm(regeneratorRuntime.mark((function e(t){var n,r,a,i,o,s,u,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}return e.abrupt("return");case 2:for(i in n=[],r=[],a=[],t)"number"!=typeof(o=t[i])&&(s=o,n.push(s.data()),r.push(i),a.push(s));if(!(n.length>0)){e.next=12;break}return e.next=9,Promise.all(n);case 9:for(u=e.sent,l=0;l<u.length;++l)t[r[l]]=u[l][0];mx(a);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $R(e){if(null!=e)for(var t in e){var n=e[t];"number"!=typeof n&&n.dispose()}}YR.className="InputLayer",ax(YR),function(e){e[e.SILENT=0]="SILENT",e[e.VERBOSE=1]="VERBOSE"}(XR||(XR={}));var eA=function(){function e(){this.validationData=null}var t=e.prototype;return t.setParams=function(e){this.params=e},t.onEpochBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.onEpochEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.onBatchBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.onBatchEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),t.onTrainBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.onTrainEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t.setModel=function(e){},e}(),tA=function(){function e(e,t){void 0===t&&(t=10),null==e&&(e=[]),this.callbacks=e,this.queueLength=t}var t=e.prototype;return t.append=function(e){this.callbacks.push(e)},t.setParams=function(e){for(var t,n=tv(this.callbacks);!(t=n()).done;){t.value.setParams(e)}},t.setModel=function(e){for(var t,n=tv(this.callbacks);!(t=n()).done;){t.value.setModel(e)}},t.onEpochBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=tv(this.callbacks);case 2:if((a=r()).done){e.next=8;break}return i=a.value,e.next=6,i.onEpochBegin(t,n);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.onEpochEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=tv(this.callbacks);case 2:if((a=r()).done){e.next=8;break}return i=a.value,e.next=6,i.onEpochEnd(t,n);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.onBatchBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=tv(this.callbacks);case 2:if((a=r()).done){e.next=8;break}return i=a.value,e.next=6,i.onBatchBegin(t,n);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.onBatchEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==n&&(n={}),r=tv(this.callbacks);case 2:if((a=r()).done){e.next=8;break}return i=a.value,e.next=6,i.onBatchEnd(t,n);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.onTrainBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==t&&(t={}),n=tv(this.callbacks);case 2:if((r=n()).done){e.next=8;break}return a=r.value,e.next=6,a.onTrainBegin(t);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.onTrainEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null==t&&(t={}),n=tv(this.callbacks);case 2:if((r=n()).done){e.next=8;break}return a=r.value,e.next=6,a.onTrainEnd(t);case 6:e.next=2;break;case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}(),nA=function(e){function t(){return e.call(this)||this}qm(t,e);var n=t.prototype;return n.onEpochBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.seen=0,this.totals={};case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.onBatchEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i,o=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(i in null==n&&(n={}),r=null==n.size?0:n.size,this.seen+=r,a=function(e){var t=n[e];if("number"==typeof t)o.totals.hasOwnProperty(e)||(o.totals[e]=0),o.totals[e]=o.totals[e]+t*r;else{var a;e in o.totals?a=o.totals[e]:o.totals[e]=0;var i=dx((function(){return xx(o.totals[e],Nx(t,r))}));o.totals[e]=i,null!=a&&a.dispose()}},n)a(i);case 5:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onEpochEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i,o=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n){e.next=9;break}r=function(){var e=i.value;if(null==o.totals[e])return"continue";"number"==typeof o.totals[e]?n[e]=o.totals[e]/o.seen:dx((function(){var t=Nx(kx(1,o.seen),o.totals[e]);n[e]=t,o.totals[e].dispose(),vx(n[e])}))},a=tv(this.params.metrics);case 3:if((i=a()).done){e.next=9;break}if("continue"!==r()){e.next=7;break}return e.abrupt("continue",7);case 7:e.next=3;break;case 9:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t}(eA),rA=function(e){function t(){return e.apply(this,arguments)||this}qm(t,e);var n=t.prototype;return n.onTrainBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.epoch=[],this.history={};case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.onEpochEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(r in null==n&&(n={}),this.epoch.push(t),n)null==this.history[r]&&(this.history[r]=[]),this.history[r].push(n[r]);case 3:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.syncData=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a,i,o,s,u,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(a in t=[],n=[],r=[],this.history)for(i=this.history[a],o=0;o<i.length;++o)"number"!=typeof i[o]&&(s=i[o],t.push(s.data()),n.push(a),r.push(o));return e.next=6,Promise.all(t);case 6:for(u=e.sent,l=0;l<u.length;++l)this.history[n[l]][r[l]].dispose(),this.history[n[l]][r[l]]=u[l][0];case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(eA),aA=function(e){function t(t,n){var r;if((r=e.call(this)||this).currentEpoch=0,r.yieldEvery=n||"auto","auto"===r.yieldEvery&&(r.yieldEvery=125),"never"===r.yieldEvery&&null!=t.onYield)throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");return Fv(r.yieldEvery)&&(r.maybeWait=function(e,t){var n,r=yg();return function(){var a=yg();return a-r<t?n:(r=a,n=e.apply(void 0,arguments))}}(r.maybeWait.bind(Qm(r)),r.yieldEvery)),r.trainBegin=t.onTrainBegin,r.trainEnd=t.onTrainEnd,r.epochBegin=t.onEpochBegin,r.epochEnd=t.onEpochEnd,r.batchBegin=t.onBatchBegin,r.batchEnd=t.onBatchEnd,r.yield=t.onYield,r}qm(t,e);var n=t.prototype;return n.maybeWait=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n,r){var a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=[],null==this.yield){e.next=5;break}return e.next=4,ZR(r);case 4:a.push(this.yield(t,n,r));case 5:return a.push(rT()),e.next=8,Promise.all(a);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),n.onEpochBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.currentEpoch=t,null==this.epochBegin){e.next=6;break}return e.next=4,ZR(n);case 4:return e.next=6,this.epochBegin(t,n);case 6:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onEpochEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=[],null==this.epochEnd){e.next=5;break}return e.next=4,ZR(n);case 4:r.push(this.epochEnd(t,n));case 5:return"epoch"===this.yieldEvery&&r.push(rT()),e.next=8,Promise.all(r);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onBatchBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==this.batchBegin){e.next=5;break}return e.next=3,ZR(n);case 3:return e.next=5,this.batchBegin(t,n);case 5:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onBatchEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=[],null==this.batchEnd){e.next=5;break}return e.next=4,ZR(n);case 4:r.push(this.batchEnd(t,n));case 5:return"batch"===this.yieldEvery?r.push(rT()):Fv(this.yieldEvery)&&r.push(this.maybeWait(this.currentEpoch,t,n)),e.next=8,Promise.all(r);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onTrainBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==this.trainBegin){e.next=5;break}return e.next=3,ZR(t);case 3:return e.next=5,this.trainBegin(t);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.onTrainEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==this.trainEnd){e.next=5;break}return e.next=3,ZR(t);case 3:return e.next=5,this.trainEnd(t);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(eA);function iA(e,t){return null==e&&(e={}),e instanceof eA?[e]:Array.isArray(e)&&e[0]instanceof eA?e:tE(e).map((function(e){return new aA(e,t)}))}var oA=function(){function e(){}return e.registerCallbackConstructor=function(t,n){lv(t>=0&&Number.isInteger(t),(function(){return"Verbosity level is expected to be an integer >= 0, but got "+t})),e.checkForDuplicate(n),null==e.constructors[t]&&(e.constructors[t]=[]),e.constructors[t].push(n)},e.checkForDuplicate=function(t){for(var n in e.constructors){e.constructors[+n].forEach((function(e){if(e===t)throw new XC("Duplicate callback constructor.")}))}},e.clear=function(){e.constructors={}},e.createCallbacks=function(t){var n=[];for(var r in e.constructors){var a=+r;t>=a&&n.push.apply(n,e.constructors[a])}return n.map((function(e){return new e}))},e}();function sA(e,t,n,r,a,i,o,s,u){var l=new rA,c=[new nA].concat(oA.createCallbacks(t));null!=e&&c.push.apply(c,e),c.push(l);var p=new tA(c);return p.setParams({epochs:n,initialEpoch:r,samples:a,steps:i,batchSize:o,verbose:t,doValidation:s,metrics:u}),{callbackList:p,history:l}}function uA(e,t,n){return void 0===t&&(t={}),void 0===n&&(n=!1),oE(e,rx.getMap().classNameMap,t,"layer",n)}function lA(e,t){return dx((function(){"float32"!==e.dtype&&(e=e.asType("float32"));var n=gk(nR(e),t,!0),r=Kw(n.shape,HC()),a=ZN(Mk(n,r));return kx(e,a)}))}function cA(e,t){return dx((function(){return Lk(nR(vk(t,e)),-1)}))}function pA(e,t){return dx((function(){return Lk(Ix(vk(t,e)),-1)}))}function hA(e,t){return dx((function(){var n=vk(e,t),r=hw(Ix(e),HC(),Number.MAX_VALUE),a=Ix(kx(n,r));return Nx(100,Lk(a,-1))}))}function fA(e,t){return dx((function(){var n=hw(t,HC(),Number.MAX_VALUE),r=sk(xx(1,n)),a=hw(e,HC(),Number.MAX_VALUE),i=sk(xx(1,a));return Lk(nR(vk(r,i)),-1)}))}function dA(e,t,n){return void 0===n&&(n=!1),dx((function(){if(n)t=HN(t);else{var r=gk(t,t.shape.length-1,!0);t=kx(t,r)}return t=hw(t,HC(),1-HC()),hk(gk(Nx(e.toFloat(),sk(t)),t.shape.length-1))}))}function mA(e,t,n){return void 0===n&&(n=!1),dx((function(){var r,a,i=Xw((r=e,a=[WE(r.shape)],r.reshape(a))).toInt(),o=(t=hw(t,HC(),1-HC())).shape;return dA(Sb(i,o[o.length-1]).reshape(o),t,n)}))}function vA(e,t){return dx((function(){var n;return n=hw(t,HC(),1-HC()),n=sk(kx(n,vk(1,n))),Lk(function(e,t){if(!dv(e.shape,t.shape))throw new XC("logits and labels must have the same shape, but got shapes "+JSON.stringify(e.shape)+" and "+JSON.stringify(t.shape));return dx((function(){var n=t.relu(),r=t.abs().neg();return n.sub(t.mul(e)).add(r.exp().log1p())}))}(e,n),-1)}))}function gA(e,t){return dx((function(){var n=hw(e,HC(),1),r=hw(t,HC(),1);return gk(Nx(e,sk(kx(n,r))),-1)}))}function yA(e,t){return dx((function(){var n=lA(e,-1),r=lA(t,-1),a=Nx(n,r);return hk(gk(a,-1))}))}oA.constructors={};var bA={meanSquaredError:cA,meanAbsoluteError:pA,meanAbsolutePercentageError:hA,meanSquaredLogarithmicError:fA,squaredHinge:function(e,t){return dx((function(){var n=Mk(0,vk(1,Nx(e,t)));return Lk(nR(n),-1)}))},hinge:function(e,t){return dx((function(){var n=Mk(0,vk(1,Nx(e,t)));return Lk(n,-1)}))},categoricalHinge:function(e,t){return dx((function(){var n=gk(Nx(e,t),-1),r=mk(Nx(vk(1,e),t),-1);return Mk(0,xx(1,vk(r,n)))}))},logcosh:function(e,t){return dx((function(){var n=Math.log(2),r=vk(t,e),a=vk(xx(r,fk(Nx(-2,r))),n);return Lk(a,-1)}))},categoricalCrossentropy:dA,sparseCategoricalCrossentropy:mA,binaryCrossentropy:vA,kullbackLeiblerDivergence:gA,poisson:function(e,t){return dx((function(){var n=sk(xx(HC(),t));return Lk(vk(t,Nx(e,n)),-1)}))},cosineProximity:yA};function xA(e){if("string"==typeof e){if(e in bA)return bA[e];var t="Unknown loss "+e;throw e.toLowerCase().includes("softmaxcrossentropy")&&(t="Unknown loss "+e+'. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy'),new XC(t)}return e}function wA(e,t){return dx((function(){var n=Nx(.5,Xk(t)),r=HE(Jw(t,n),e.dtype);return Lk(Mw(e,r),-1)}))}function kA(e,t){return dx((function(){return HE(Mw(Ax(e,-1),Ax(t,-1)),"float32")}))}function NA(e,t){return dx((function(){return Ek(e.equal(1),t.equal(1)).sum().cast("float32")}))}function IA(e,t){return dx((function(){var n=NA(e,t),r=function(e,t){return dx((function(){return Ek(e.equal(0),t.equal(1)).sum().cast("float32")}))}(e,t),a=n.add(r);return Lw(Jw(a,0),n.div(a),0).cast("float32")}))}function SA(e,t){return dx((function(){var n=NA(e,t),r=function(e,t){return dx((function(){return Ek(e.equal(1),t.equal(0)).sum().cast("float32")}))}(e,t),a=n.add(r);return Lw(Jw(a,0),n.div(a),0).cast("float32")}))}function TA(e,t){return vA(e,t)}function CA(e,t){return e.rank===t.rank&&(e=e.squeeze([e.rank-1])),(t=t.argMax(-1)).dtype!==e.dtype&&(t=t.asType(e.dtype)),Mw(e,t).asType("float32")}var EA=dA,RA=mA,AA={binaryAccuracy:wA,categoricalAccuracy:kA,precision:IA,categoricalCrossentropy:EA,sparseCategoricalCrossentropy:RA,mse:cA,MSE:cA,mae:pA,MAE:pA,mape:hA,MAPE:hA,cosine:yA};function DA(e){if("string"==typeof e&&e in AA)return AA[e];if("string"!=typeof e&&null!=e)return e;throw new XC("Unknown metric "+e)}function FA(e){if(QC(null!==e,"Unknown LossOrMetricFn "+e),"string"==typeof e)return e;for(var t,n=0,r=Object.keys(bA);n<r.length;n++){var a=r[n];if(bA[a]===e){t=a;break}}if(void 0!==t)return t;for(var i=0,o=Object.keys(AA);i<o.length;i++){var s=o[i];if(AA[s]===e){t=s;break}}return void 0!==t?t:e.name}function _A(e,t,n){if(void 0===n&&(n=!1),null==e||"object"!=typeof e||Object.getPrototypeOf(e)!==Object.prototype||!function e(t){if(null===t)return!0;if("object"==typeof t){if(Object.getPrototypeOf(t)===Object.prototype){for(var n=Object.keys(t),r=0,a=n;r<a.length;r++){var i=a[r];if("string"!=typeof i)return!1;if(!e(t[i]))return!1}return!0}if(Array.isArray(t)){for(var o,s=tv(t);!(o=s()).done;){var u=o.value;if(!e(u))return!1}return!0}return!1}var l=typeof t;return"string"===l||"number"===l||"boolean"===l}(e))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){var r=JSON.stringify(e);r.length>1048576&&console.warn('User-defined metadata of model "'+t+'" is too large in size (length='+r.length+" when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= 1048576.")}}function OA(e,t,n,r){void 0===r&&(r=console.log);var a,i=function(e){var t=!0,n=[],r=[];for(var a in e.nodesByDepth)n.push(e.nodesByDepth[a]);for(var i=0,o=n;i<o.length;i++){var s=o[i];if(s.length>1||1===s.length&&s[0].inboundLayers.length>1){t=!1;break}r.push.apply(r,s)}if(t)for(var u,l=tv(e.layers);!(u=l()).done;){for(var c,p=u.value,h=!1,f=tv(p.inboundNodes);!(c=f()).done;){var d=c.value;if(-1!==r.indexOf(d)){if(h){t=!1;break}h=!0}}if(!t)break}return t}(e),o=["Layer (type)","Output shape","Param #"];if(i?(t=t||65,n=n||[.45,.85,1]):(t=t||98,n=n||[.33,.55,.67,1]),n[n.length-1]<=1&&(n=n.map((function(e){return Math.floor(t*e)}))),!i)for(var s in o.push("Receives inputs"),a=[],e.nodesByDepth){var u;(u=a).push.apply(u,e.nodesByDepth[s])}r("_".repeat(t)),MA(o,n,r),r("=".repeat(t));for(var l=e.layers,c=0;c<l.length;++c)i?LA(l[c],n,r):zA(l[c],n,a,r),r((c===l.length-1?"=":"_").repeat(t));e.checkTrainableWeightsConsistency();var p=function(e){var t;t=null!=e.collectedTrainableWeights?PR(e.collectedTrainableWeights):PR(e.trainableWeights);return t}(e),h=PR(e.nonTrainableWeights);r("Total params: "+(p+h)),r("Trainable params: "+p),r("Non-trainable params: "+h),r("_".repeat(t))}function MA(e,t,n){void 0===n&&(n=console.log);for(var r="",a=0;a<e.length;++a)a>0&&(r=r.slice(0,r.length-1)+" "),r=(r+=e[a]).slice(0,t[a]),r+=" ".repeat(t[a]-r.length);n(r)}function LA(e,t,n){var r;try{r=JSON.stringify(e.outputShape)}catch(e){r="multiple"}MA([e.name+" ("+e.getClassName()+")",r,e.countParams().toString()],t,n)}function zA(e,t,n,r){var a;try{a=JSON.stringify(e.outputShape)}catch(e){a="multiple"}for(var i,o=[],s=tv(e.inboundNodes);!(i=s()).done;){var u=i.value;if(!(null!=n&&n.length>0&&-1===n.indexOf(u)))for(var l=0;l<u.inboundLayers.length;++l){var c=u.inboundLayers[l].name,p=u.nodeIndices[l],h=u.tensorIndices[l];o.push(c+"["+p+"]["+h+"]")}}var f=e.name,d=e.getClassName(),m=0===o.length?"":o[0];MA([f+" ("+d+")",a,e.countParams().toString(),m],t,r);for(var v=1;v<o.length;++v)MA(["","","",o[v]],t,r)}function PA(e,t,n){return("inboundNodes"===e||"outputLayers"===e||"inputLayers"===e)&&0===t&&"string"==typeof n}function BA(e,t){if(null===e)return null;if("string"==typeof e)return rE(e);if("number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Array){for(var n=[],r=e.length,a=0;a<r;++a){var i=e[a];PA(t,a,i)?n.push(i):n.push(BA(i,t))}return n}for(var o={},s=0,u=Object.keys(e);s<u.length;s++){var l=u[s],c=e[l];if("name"===l&&"string"==typeof c)o[l]=c;else{var p=rE(l);o[p]=BA(c,p)}}return o}var WA=function(){function e(t){if(this.id2Value={},this.id2Mask={},this.name2Id={},t instanceof e)for(var n in t.id2Value)this.id2Value[n]=t.id2Value[n],n in t.id2Mask&&(this.id2Mask[n]=t.id2Mask[n]);else{if(null==t)return;for(var r,a=tv(t);!(r=a()).done;){var i=r.value;this.add(i.key,i.value)}}}var t=e.prototype;return t.add=function(e,t,n){if(null!=this.id2Value[e.id])throw new XC("Duplicate key: name="+e.name+", id="+e.id);return this.id2Value[e.id]=function(e,t){if(null==e.dtype||e.dtype===t.dtype)return t;try{return rb(t,e.dtype)}catch(n){throw new XC("The dtype of the feed ("+t.dtype+") can not be cast to the dtype of the key '"+e.name+"' ("+e.dtype+").")}}(e,t),this.name2Id[e.name]=e.id,null!=n&&(this.id2Mask[e.id]=n),this},t.addFeed=function(e){this.add(e.key,e.value)},t.hasKey=function(e){return null!=this.id2Value[e.id]},t.names=function(){return Object.keys(this.name2Id)},t.getValue=function(e){if(e instanceof GR){if(null==this.id2Value[e.id])throw new XC("Nonexistent key: "+e.name);return this.id2Value[e.id]}var t=this.name2Id[e];if(null==t)throw new XC("Feed dict has no SymbolicTensor name: "+e);return this.id2Value[t]},t.getMask=function(e){if(e instanceof GR){if(null==this.id2Value[e.id])throw new XC("Nonexistent key: "+e.name);return this.id2Mask[e.id]}var t=this.name2Id[e];if(null==t)throw new XC("Feed dict has no SymbolicTensor name: "+e);return this.id2Mask[t]},t.disposeMasks=function(){null!=this.id2Mask&&mx(this.id2Mask)},e}(),VA={},UA={};function GA(e,t,n,r){for(var a,i=null!=n&&n.training,o=Array.isArray(e),s=o?e:[e],u=s.map((function(e){return e.name})),l=[],c=t.names(),p=tv(u);!(a=p()).done;){var h=a.value;-1!==c.indexOf(h)?l.push(t.getValue(h)):l.push(null)}null!=r&&(r.maxNumTensors=-1/0,r.minNumTensors=1/0);var f,d,m=u.join(",")+"|"+t.names().join(",");if(null==VA[m]){var v=function(e,t){lv(null!=e&&e.length>0,(function(){return"Expected at least one fetch, got none"}));var n=[],r={};if(1===e.length){var a=HA(e[0],t);n=a.sorted,r=a.recipientMap}else for(var i,o=new Set,s=tv(e);!(i=s()).done;){for(var u,l=HA(i.value,t),c=l.sorted,p=l.recipientMap,h=tv(c);!(u=h()).done;){var f=u.value;o.has(f.name)||(n.push(f),o.add(f.name))}var d=function(e){null==r[e]&&(r[e]=new Set),p[e].forEach((function(t){return r[e].add(t)}))};for(var m in p)d(m)}return{sorted:n,recipientCounts:jA(r)}}(s,t);f=v.sorted,d=v.recipientCounts,VA[m]=f,UA[m]=d}f=VA[m],d={},i||Object.assign(d,UA[m]);for(var g=new WA(t),y=0;y<f.length;++y){if(null!=r){var b=fx().numTensors;b>r.maxNumTensors&&(r.maxNumTensors=b),b<r.minNumTensors&&(r.minNumTensors=b)}var x=f[y],w=x.sourceLayer;if(!(w instanceof YR)){for(var k,N=[],I=[],S=[],T=!1,C=tv(x.inputs);!(k=C()).done;){var E=k.value,R=g.getValue(E),A=g.getMask(E);N.push(R),I.push(A),null!=A&&(T=!0),i||(d[E.name]--,0!==d[E.name]||t.hasKey(E)||-1!==u.indexOf(E.name)||R.isDisposed||!0===E.sourceLayer.stateful||S.push(R))}T&&((n=n||{}).mask=I[0]);var D=tE(w.apply(N,n)),F=null;w.supportsMasking&&(F=w.computeMask(N,I));for(var _=qA(x),O=Array.isArray(_)?_:[_],M=0;M<O.length;++M){g.hasKey(O[M])||g.add(O[M],D[M],Array.isArray(F)?F[0]:F);var L=u.indexOf(O[M].name);-1!==L&&(l[L]=D[M])}i||mx(S)}}return g.disposeMasks(),o?l:l[0]}function jA(e){var t={};for(var n in e)t[n]=e[n].size;return t}function HA(e,t){for(var n,r=new Set,a=[],i={},o=tv(t.names());!(n=o()).done;){var s=n.value;r.add(s)}var u=[],l=[];for(u.push(e);u.length>0;){var c=u[u.length-1];if(r.has(c.name))u.pop();else{var p=l[l.length-1]===u.length-1;if(0===c.inputs.length||p)u.pop(),a.push(c),r.add(c.name),p&&l.pop();else{l.push(u.length-1);for(var h,f=tv(c.inputs);!(h=f()).done;){var d=h.value;null==i[d.name]&&(i[d.name]=new Set),i[d.name].add(c.name),r.has(d.name)||u.push(d)}}}}return{sorted:a,recipientMap:i}}function qA(e){var t;if(1===e.sourceLayer.inboundNodes.length)t=e.sourceLayer.output;else{for(var n=null,r=0;r<e.sourceLayer.inboundNodes.length;++r)for(var a,i=tv(e.sourceLayer.inboundNodes[r].outputTensors);!(a=i()).done;){if(a.value.id===e.id){n=r;break}}t=e.sourceLayer.getOutputAt(n)}return t}function KA(e,t,n){var r=t.length;if(null==e||Array.isArray(e)&&0===e.length)return t.map((function(e){return null}));if(1===r)return Array.isArray(e)&&1===e.length?e:"object"==typeof e&&t[0]in e?[e[t[0]]]:[e];if(Array.isArray(e)){if(e.length!==r)throw new Error("Provided "+n+" is an array of "+e.length+" element(s), but the model has "+r+" outputs. Make sure a set of weights is provided for each model output.");return e}if("object"==typeof e&&Object.keys(e).length>0&&"object"==typeof e[Object.keys(e)[0]]){var a=[];return t.forEach((function(t){t in e?a.push(e[t]):a.push(null)})),a}throw new Error("The model has multiple ("+r+") outputs, so "+n+" must be either an array with "+r+" elements or an object with "+t+" keys. Provided "+n+" not understood: "+JSON.stringify(e))}function XA(e,t){return KA(e,t,"classWeight")}function YA(e,t,n,r){return JA.apply(this,arguments)}function JA(){return(JA=Gm(regeneratorRuntime.mark((function e(t,n,r,a){var i,o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n&&null==a){e.next=2;break}throw new Error("Support sampleWeight is not implemented yet");case 2:if(null==r){e.next=15;break}return i=dx((function(){if(1===t.shape.length)return t.clone();if(2===t.shape.length){if(t.shape[1]>1){return t.argMax(1)}if(1===t.shape[1])return t.reshape([t.shape[0]]);throw new Error("Encountered unexpected last-dimension size ("+t.shape[1]+") during handling of class weights. The size is expected to be >= 1.")}throw new Error("Unexpected rank of target (y) tensor ("+t.rank+") during handling of class weights. The rank is expected to be 1 or 2.")})),e.t0=Array,e.next=7,i.data();case 7:return e.t1=e.sent,o=e.t0.from.call(e.t0,e.t1),mx(i),s=[],o.forEach((function(e){if(null==r[e])throw new Error("classWeight must contain all classes in the training data. The class "+e+" exists in the data but not in classWeight");s.push(r[e])})),e.abrupt("return",aI(s,"float32"));case 15:return e.abrupt("return",null);case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ZA(e,t){return Nx(e,t)}function QA(e,t){var n,r,a=t;n=a.xs,r=a.ys,lv(null!=n&&null!=r,(function(){return"A Dataset iterator for fitDataset() is expected to generate objects of the form `{xs: xVal, ys: yVal}`, where the two values may be `tf.Tensor`, an array of Tensors, or a map of string to Tensor.  The provided Dataset instead generates "+t}));var i=$A("input",e.inputNames,n),o=$A("output",e.outputNames,r),s=i[0].shape[0];lv(i.length===e.inputs.length,(function(){return"LayersModel has "+e.inputs.length+" inputs, but the dataset provides "+i.length+" inputs.  (Expected input keys: "+JSON.stringify(e.inputNames)+")"})),lv(o.length===e.outputs.length,(function(){return"LayersModel has "+e.outputs.length+" outputs, but the dataset provides "+o.length+" outputs.  (Expected output keys: "+JSON.stringify(e.outputNames)+")"}));for(var u=function(t){lv(i[t].shape[0]===s,(function(){return"Batch size mismatch: input "+e.inputNames[t]+" has "+i[t].shape[0]+"; expected  "+s+" based on input "+e.inputNames[0]+"."}))},l=0;l<i.length;l++)u(l);for(var c=function(t){lv(o[t].shape[0]===s,(function(){return"Batch size mismatch: output "+e.outputNames[t]+" has "+o[t].shape[0]+"; expected  "+s+" based on input "+e.inputNames[0]+"."}))},p=0;p<o.length;p++)c(p);return{xs:i,ys:o}}function $A(e,t,n){if(n instanceof Fg)return[n];if(Array.isArray(n))return lv(n.length===t.length,(function(){return"Received an array of "+n.length+" Tensors, but expected "+t.length+" to match the "+e+" keys "+t+"."})),n;for(var r,a=[],i=tv(t);!(r=i()).done;){var o=r.value;if(null==n[o])throw new XC("The feature data generated by the dataset lacks the required "+e+" key '"+o+"'.");a.push(n[o])}return a}function eD(e){if(3===e.length)throw new YC("Validation with sample weights is not implemented yet.");return{xs:e[0],ys:e[1]}}function tD(e,t,n){return nD.apply(this,arguments)}function nD(){return(nD=Gm(regeneratorRuntime.mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h,f,d,m,v,g,y,b,x,w,k,N,I,S,T,C,E,R,A,D,F,_,O,M,L;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null!=r.batchesPerEpoch,lv(null!=t.optimizer,(function(){return"You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig)."})),lv(null!=r,(function(){return"For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call."})),lv(null!=r.epochs&&r.epochs>0&&Number.isInteger(r.epochs),(function(){return"For fitDataset(), config.epochs is expected to be a positive integer, but got "+r.epochs})),lv(!a||r.batchesPerEpoch>0&&Number.isInteger(r.batchesPerEpoch),(function(){return"For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got "+r.batchesPerEpoch})),lv(null==r.validationSplit,(function(){return"`validationSplit` is not supported by `fitDataset()`. Use validationData instead."})),!t.isTraining){e.next=8;break}throw new Error("Cannot start training because another fit() call is ongoing.");case 8:return t.isTraining=!0,e.prev=9,(i=null!=r.validationData)&&(aD(r.validationData)?lv(null==r.validationBatches||r.validationBatches>0&&Number.isInteger(r.validationBatches),(function(){return"For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got "+r.validationBatches})):(u=eD(r.validationData),o=u.xs,s=u.ys)),l=t.makeTrainFunction(),c=t.getDedupedMetricsNames(),p=i?c.slice().concat(c.map((function(e){return"val_"+e}))):c.slice(),h=iA(r.callbacks,r.yieldEvery),f=null==r.verbose?1:r.verbose,d=sA(h,f,r.epochs,null,null,rD(n,r),null,i,p),m=d.callbackList,v=d.history,m.setModel(t),t.history=v,e.next=22,m.onTrainBegin();case 22:return t.stopTraining_=!1,g=null==r.initialEpoch?0:r.initialEpoch,e.next=26,n.iterator();case 26:y=e.sent;case 27:if(!(g<r.epochs)){e.next=98;break}return b={},e.next=31,m.onEpochBegin(g);case 31:if(x=0,w=0,a){e.next=37;break}return e.next=36,n.iterator();case 36:y=e.sent;case 37:if(a&&!(x<r.batchesPerEpoch)){e.next=91;break}return e.next=40,y.next();case 40:if(k=e.sent,!a||!k.done){e.next=44;break}return console.warn("You provided `batchesPerEpoch` as "+r.batchesPerEpoch+", but your dataset iterator ran out of data after "+x+" batches; interrupting training. Make sure that your dataset can generate at least `batchesPerEpoch * epochs` batches (in this case, "+r.batchesPerEpoch*r.epochs+" batches). You may need to use the repeat() function when building your dataset."),e.abrupt("break",91);case 44:if(null==k.value){e.next=73;break}return N=QA(t,k.value),I=N.xs,S=N.ys,(T={}).batch=w,T.size=I[0].shape[0],e.next=51,m.onBatchBegin(w,T);case 51:if(C=[],null==r.classWeight){e.next=64;break}E=XA(r.classWeight,t.outputNames),R=0;case 55:if(!(R<E.length)){e.next=64;break}return e.t0=C,e.next=59,YA(S[R],null,E[R]);case 59:e.t1=e.sent,e.t0.push.call(e.t0,e.t1);case 61:++R,e.next=55;break;case 64:for(A=I.concat(S).concat(C),D=l(A),mx(A),F=0;F<c.length;++F)_=c[F],O=D[F],T[_]=O,vx(O);return e.next=70,m.onBatchEnd(w,T);case 70:$R(T),w++,x++;case 73:if(!(a?x>=r.batchesPerEpoch:k.done)){e.next=87;break}if(!i){e.next=86;break}if(M=void 0,!aD(r.validationData)){e.next=84;break}return e.t2=tE,e.next=80,t.evaluateDataset(r.validationData,{batches:r.validationBatches});case 80:e.t3=e.sent,M=(0,e.t2)(e.t3),e.next=85;break;case 84:M=tE(t.evaluate(o,s,{batchSize:null==r.validationBatchSize?32:r.validationBatchSize,verbose:0}));case 85:for(L=0;L<t.metricsNames.length;++L)b["val_"+t.metricsNames[L]]=M[L];case 86:return e.abrupt("break",91);case 87:if(!t.stopTraining_){e.next=89;break}return e.abrupt("break",91);case 89:e.next=37;break;case 91:return e.next=93,m.onEpochEnd(g,b);case 93:if(g++,!t.stopTraining_){e.next=96;break}return e.abrupt("break",98);case 96:e.next=27;break;case 98:return e.next=100,m.onTrainEnd();case 100:return e.next=102,t.history.syncData();case 102:return e.abrupt("return",t.history);case 103:return e.prev=103,t.isTraining=!1,e.finish(103);case 106:case"end":return e.stop()}}),e,null,[[9,,103,106]])})))).apply(this,arguments)}function rD(e,t){var n=null;return null!=t.batchesPerEpoch?n=t.batchesPerEpoch:Number.isFinite(e.size)&&(n=e.size),n}function aD(e){return"function"==typeof e.iterator}function iD(e){return"function"==typeof e.next}function oD(e,t,n){return sD.apply(this,arguments)}function sD(){return(sD=Gm(regeneratorRuntime.mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null!=(r=r||{}).batches,i=t.testFunction,o=[],!(r.verbose>0)){e.next=6;break}throw new YC("Verbose mode is not implemented yet.");case 6:if(lv(!a||r.batches>0&&Number.isInteger(r.batches),(function(){return"Test loop expects `batches` to be a positive integer, but received "+JSON.stringify(r.batches)})),!iD(n)){e.next=11;break}e.t0=n,e.next=14;break;case 11:return e.next=13,n.iterator();case 13:e.t0=e.sent;case 14:s=e.t0,u=0,l=0,c=regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.next();case 2:if(n=e.sent,o=dx((function(){return n.value&&function(){var e=QA(t,n.value),r=e.xs,a=e.ys,s=r.concat(a),c=dx((function(){return i(s)}));if(mx(s),0===l)for(var p=0;p<c.length;++p)o.push(_N(0));for(var h=s[0].shape[0],f=function(e){var t=c[e],n=o[e];o[e]=dx((function(){return xx(o[e],Nx(h,t))})),l>0&&mx(n)},d=0;d<c.length;++d)f(d);mx(c),u+=h,++l}(),o})),!n.done){e.next=7;break}return a&&console.warn("Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least `batches` batches (in this case, "+r.batches+" batches). You may need to use the repeat() function when building your dataset."),e.abrupt("return","break");case 7:case"end":return e.stop()}}),e)}));case 18:if(a&&!(l<r.batches)){e.next=25;break}return e.delegateYield(c(),"t1",20);case 20:if("break"!==e.t1){e.next=23;break}return e.abrupt("break",25);case 23:e.next=18;break;case 25:for(p=0;p<o.length;++p)h=o[p],o[p]=kx(o[p],u),mx(h);return e.abrupt("return",eE(o));case 27:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function uD(e){lv(e>0&&Number.isInteger(e),(function(){return"batchSize is required to be a positive integer, but got "+e}))}function lD(e,t,n){return null==e?[null]:Array.isArray(e)?e.map((function(e){return KE(e,t,n-t)})):KE(e,t,n-t)}function cD(e,t){return dx((function(){return null==e?null:Array.isArray(e)?e.map((function(e){return cD(e,t)})):tR(e,"int32"===t.dtype?t:t.toInt())}))}function pD(e,t){for(var n=[],r=0,a=null;r<e;)(a=r+t)>=e&&(a=e),n.push([r,a]),r=a;return n}function hD(e,t,n,r,a,i,o,s,u,l,c,p,h,f,d){return fD.apply(this,arguments)}function fD(){return(fD=Gm(regeneratorRuntime.mark((function e(t,n,r,a,i,o,s,u,l,c,p,h,f,d,m){var v,g,y,b,x,w,k,N;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==i&&(i=32),null==o&&(o=1),null==p&&(p=!0),null==f&&(f=0),v=!1,null!=l&&null!=c&&(v=!0),null==m){e.next=10;break}if(v=!0,null!=d){e.next=10;break}throw new XC("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");case 10:return null!=(g=t.checkNumSamples(r,i,d,"steps_per_epoch"))&&(y=jE(0,g)),null==s&&(s=1),b=sA(u,s,o,f,g,d,i,v,h),x=b.callbackList,w=b.history,x.setModel(t),t.history=w,e.next=18,x.onTrainBegin();case 18:t.stopTraining_=!1,k=regeneratorRuntime.mark((function e(o){var s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,x.onEpochBegin(o);case 2:if(s={},null==d){e.next=7;break}throw new YC("stepsPerEpoch mode is not implemented yet.");case 7:return e.delegateYield(regeneratorRuntime.mark((function e(){var o,u,h,f;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("batch"!==p){e.next=4;break}throw new YC("batch shuffling is not implemneted yet");case 4:p&&iv(y);case 5:o=aI(y),u=pD(g,i),h=regeneratorRuntime.mark((function e(p){var h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h={},e.next=3,x.onBatchBegin(p,h);case 3:return dx((function(){var e=u[p][0],f=u[p][1],d=KE(o,e,f-e);h.batch=p,h.size=f-e;for(var m=cD(r,d),g=n(m),y=0;y<a.length;++y){var b=a[y],x=g[y];h[b]=x,vx(x)}if(p===u.length-1&&v)for(var w=t.testLoop(l,c,i),k=0;k<a.length;++k){var N=a[k],I=w[k];vx(I),s["val_"+N]=I}})),e.next=6,x.onBatchEnd(p,h);case 6:if($R(h),!t.stopTraining_){e.next=9;break}return e.abrupt("return","break");case 9:case"end":return e.stop()}}),e)})),f=0;case 9:if(!(f<u.length)){e.next=17;break}return e.delegateYield(h(f),"t0",11);case 11:if("break"!==e.t0){e.next=14;break}return e.abrupt("break",17);case 14:++f,e.next=9;break;case 17:o.dispose();case 18:case"end":return e.stop()}}),e)}))(),"t0",8);case 8:return e.next=10,x.onEpochEnd(o,s);case 10:if(!t.stopTraining_){e.next=12;break}return e.abrupt("return","break");case 12:case"end":return e.stop()}}),e)})),N=f;case 21:if(!(N<o)){e.next=29;break}return e.delegateYield(k(N),"t0",23);case 23:if("break"!==e.t0){e.next=26;break}return e.abrupt("break",29);case 26:++N,e.next=21;break;case 29:return e.next=31,x.onTrainEnd();case 31:return e.next=33,t.history.syncData();case 33:return e.abrupt("return",t.history);case 34:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function dD(e,t,n,r){return mD.apply(this,arguments)}function mD(){return(mD=Gm(regeneratorRuntime.mark((function e(t,n,r,a){var i,o,s,u,l,c,p,h,f,d,m,v,g,y,b,x,w,k,N,I,S;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===a&&(a={}),!t.isTraining){e.next=3;break}throw new Error("Cannot start training because another fit() call is ongoing.");case 3:return t.isTraining=!0,e.prev=4,uD(h=null==a.batchSize?32:a.batchSize),!1,e.next=10,t.standardizeUserData(n,r,a.sampleWeight,a.classWeight,!1,h);case 10:if(f=e.sent,i=f[0],o=f[1],p=f[2],d=!1,!(null!=a.validationData&&a.validationData.length>0)){e.next=36;break}if(d=!0,2!==a.validationData.length){e.next=22;break}s=a.validationData[0],u=a.validationData[1],e.next=27;break;case 22:if(3!==a.validationData.length){e.next=26;break}throw new YC("validationData including sample weights is not supported yet.");case 26:throw new XC("When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; "+a.validationData+" is invalid.");case 27:return!0,e.next=30,t.standardizeUserData(s,u,null,null,!0,h);case 30:v=e.sent,l=v[0],c=v[1],m=l.concat(c),e.next=37;break;case 36:null!=a.validationSplit&&a.validationSplit>0&&a.validationSplit<1?(d=!0,g=Math.floor(i[0].shape[0]*(1-a.validationSplit)),y=i[0].shape[0],l=lD(i,g,y),i=lD(i,0,g),c=lD(o,g,y),o=lD(o,0,g),m=l.concat(c)):null!=a.validationSteps&&(d=!0);case 37:return b=i.concat(o).concat(p),t.checkTrainableWeightsConsistency(),x=t.makeTrainFunction(),w=t.getDedupedMetricsNames(),d?(t.makeTestFunction(),k=t.testFunction,N=w.slice().concat(w.map((function(e){return"val_"+e})))):(k=null,m=[],N=w.slice()),I=iA(a.callbacks,a.yieldEvery),e.next=45,hD(t,x,b,w,h,a.epochs,a.verbose,I,k,m,a.shuffle,N,a.initialEpoch,null,null);case 45:return S=e.sent,e.abrupt("return",S);case 47:return e.prev=47,t.isTraining=!1,gD(i,n),gD(o,r),gD(l,s),gD(c,u),null!=p&&mx(p),e.finish(47);case 55:case"end":return e.stop()}}),e,null,[[4,,47,55]])})))).apply(this,arguments)}function vD(e){var t=[];e instanceof Fg&&(e=[e]);for(var n=0;n<e.length;++n){var r=e[n];if(1===r.rank)t.push(qE(r,1));else{if(0===r.rank)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");t.push(r)}}return t}function gD(e,t){if(null!=e){var n=[];if(t instanceof Fg)n.push(t.id);else if(Array.isArray(t))t.forEach((function(e){return n.push(e.id)}));else if(null!=t)for(var r in t){var a=t[r];n.push(a.id)}var i=[];if(e instanceof Fg)-1===n.indexOf(e.id)&&i.push(e);else if(Array.isArray(e))e.forEach((function(e){-1===n.indexOf(e.id)&&i.push(e)}));else if(null!=e)for(var o in e){var s=e[o];-1===n.indexOf(s.id)&&i.push(s)}i.forEach((function(e){e.isDisposed||e.dispose()}))}}function yD(e){return Array.isArray(e)}function bD(e){return!function(e){return e instanceof Fg}(e)&&!yD(e)}function xD(e,t,n,r,a){if(void 0===r&&(r=!0),void 0===a&&(a=""),null==t||0===t.length){if(null!=e){var i=!1;if(yD(e)&&e.length>0)i=!0;else if(bD(e)){for(var o in e)if(e.hasOwnProperty(o)){i=!0;break}}else i=!0;if(i)throw new XC("Error when checking model "+a+" expected no data, but got "+e)}return[]}if(null==e)return t.map((function(e){return null}));var s;if(bD(e)){e=e,s=[];for(var u,l=tv(t);!(u=l()).done;){var c=u.value;if(null==e[c])throw new XC('No data provided for "'+c+'". Need data for each key in: '+t);s.push(e[c])}}else if(yD(e)){if((e=e).length!==t.length)throw new XC("Error when checking model "+a+": the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see "+t.length+" Tensor(s), but instead got the following list of Tensor(s): "+e);s=e}else{if(e=e,t.length>1)throw new XC("The model "+a+" expects "+t.length+" Tensor(s), but only received one Tensor. Found: Tensor with shape "+e.shape);s=[e]}if(s=vD(s),null!=n)for(var p=0;p<t.length;++p)if(null!=n[p]){var h=s[p];if(h.shape.length!==n[p].length)throw new XC("Error when checking "+a+": expected "+t[p]+" to have "+n[p].length+" dimension(s). but got array with shape "+h.shape);for(var f=0;f<n[p].length;++f)if(0!==f||r){var d=h.shape[f],m=n[p][f];if(null!=m&&m>=0&&d!==m)throw new XC("Error when checking "+a+": expected "+t[p]+" to have shape ["+n[p]+"], but got array with shape ["+h.shape+"].")}}return s}function wD(e,t,n,r,a){var i;if(void 0===r&&(r=!0),void 0===a&&(a=""),Array.isArray(e)){if(e.length!==t.length)throw new XC("Error when checking model "+a+": the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see "+t.length+" Tensor(s), but instead got "+e.length+" Tensors(s).");i=e}else{if(t.length>1)throw new XC("The model expects "+t.length+" "+a+" Tensors, but only received one Tensor. Found: array with shape "+JSON.stringify(e.shape)+".");i=[e]}if(null!=n)for(var o=0;o<t.length;++o)if(null!=n[o]){var s=i[o];if(s.shape.length!==n[o].length)throw new XC("Error when checking "+a+": expected "+t[o]+" to have "+n[o].length+" dimension(s), but got array with shape "+JSON.stringify(s.shape));for(var u=0;u<n[o].length;++u)if(0!==u||r){var l=s.shape[u],c=n[o][u];if(null!=c&&c!==l)throw new XC("Error when checking "+a+": expected "+t[o]+" to have shape "+JSON.stringify(n[o])+" but got array with shape "+JSON.stringify(s.shape)+".")}}}var kD=function(e){function t(t){var n;return(n=e.call(this,t)||this).isTraining=!1,n}qm(t,e);var n=t.prototype;return n.summary=function(e,t,n){if(void 0===n&&(n=console.log),!this.built)throw new XC("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");OA(this,e,t,n)},n.compile=function(e){var t=this;if(null==e.loss&&(e.loss=[]),this.loss=e.loss,"string"==typeof e.optimizer)this.optimizer_=function(e){var t={Adagrad:function(){return tT.adagrad(.01)},Adadelta:function(){return tT.adadelta(1,.95,HC())},Adam:function(){return tT.adam(.001,.9,.999,HC())},Adamax:function(){return tT.adamax(.002,.9,.999,HC(),0)},RMSProp:function(){return tT.rmsprop(.001,.9,0,HC())},SGD:function(){return tT.sgd(.01)}};if(t.adagrad=t.Adagrad,t.adadelta=t.Adadelta,t.adam=t.Adam,t.adamax=t.Adamax,t.rmsprop=t.RMSProp,t.sgd=t.SGD,e in t)return t[e]();throw new XC("Unknown Optimizer "+e)}(e.optimizer),this.isOptimizerOwned=!0;else{if(!(e.optimizer instanceof qS))throw new XC("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=e.optimizer,this.isOptimizerOwned=!1}var n=[];if(Array.isArray(e.loss)||"string"==typeof e.loss||"function"==typeof e.loss)if(Array.isArray(e.loss)){if(e.loss.length!==this.outputs.length)throw new XC("When passing an Array as loss, it should have one entry per model output. The model has "+this.outputs.length+" output(s), but you passed loss="+e.loss+".");var r=e.loss;n=r.map((function(e){return xA(e)}))}else{var a=xA(e.loss);this.outputs.forEach((function(e){n.push(a)}))}else{for(var i in e.loss=e.loss,e.loss)if(-1===this.outputNames.indexOf(i))throw new XC('Unknown entry in loss dictionary: "'+i+'". Only expected the following keys: '+this.outputNames);for(var o,s=tv(this.outputNames);!(o=s()).done;){var u=o.value;null==e.loss[u]&&console.warn('Output "'+u+'" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to '+u+" during training"),n.push(xA(e.loss[u]))}}this.lossFunctions=n,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(var l=0;l<this.outputs.length;++l){var c=this.internalOutputShapes[l],p=this.outputNames[l];this.feedOutputNames.push(p),this.feedOutputShapes.push(c),this.feedLossFns.push(this.lossFunctions[l])}var h=[];this.metrics=e.metrics,this.metricsNames=["loss"],this.metricsTensors=[],ME("loss",(function(){for(var e=0;e<t.outputs.length;++e)if(-1===h.indexOf(e)){var n=t.lossFunctions[e];t.outputs.length>1&&(t.metricsTensors.push([n,e]),t.metricsNames.push(t.outputNames[e]+"_loss"))}}));var f=function(e,t){if(null==e||Array.isArray(e)&&0===e.length)return t.map((function(e){return[]}));var n;if("string"==typeof e||"function"==typeof e)n=[e];else{if(!Array.isArray(e)&&"object"!=typeof e)throw new TypeError("Type of metrics argument not understood. Expected an string,function, Array, or Object, found: "+e);n=e}if(Array.isArray(n))return t.map((function(e){return n}));for(var r,a=[],i=tv(t);!(r=i()).done;){var o=r.value,s=n.hasOwnProperty(o)?n[o]:[];Array.isArray(s)||(s=[s]),a.push(s)}return a}(e.metrics,this.outputNames),d=function(e,n,r){t.outputNames.length>1&&(n=t.outputNames[e]+"_"+n),t.metricsNames.push(n),t.metricsTensors.push([r,e])};ME("metric",(function(){for(var e=function(e){if(-1!==h.indexOf(e))return"continue";!function(n){for(var r,a,i,o,s=tv(n);!(o=s()).done;){var u=o.value;if("string"==typeof u&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(u)){var l=t.internalOutputShapes[e];1===l[l.length-1]||t.lossFunctions[e]===vA?-1!==["accuracy","acc"].indexOf(u)?a=wA:-1!==["crossentropy","ce"].indexOf(u)&&(a=TA):t.lossFunctions[e]===mA?-1!==["accuracy","acc"].indexOf(u)?a=CA:-1!==["crossentropy","ce"].indexOf(u)&&(a=RA):-1!==["accuracy","acc"].indexOf(u)?a=kA:-1!==["crossentropy","ce"].indexOf(u)&&(a=EA);var c=void 0;-1!==["accuracy","acc"].indexOf(u)?c="acc":-1!==["crossentropy","ce"].indexOf(u)&&(c="ce"),i=a,r=""+c}else{var p=DA(u);i=p,r=""+FA(u)}var h=void 0;ME(r,(function(){h=i})),d(e,r,h)}}(f[e])},n=0;n<t.outputs.length;++n)e(n)})),this.collectedTrainableWeights=this.trainableWeights},n.checkTrainableWeightsConsistency=function(){null!=this.collectedTrainableWeights&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?")},n.evaluate=function(e,t,n){void 0===n&&(n={});var r=null==n.batchSize?32:n.batchSize;uD(r);var a=this.standardizeUserDataXY(e,t,!0,r);try{var i=a[0].concat(a[1]);this.makeTestFunction();var o=this.testFunction;return eE(this.testLoop(o,i,r,n.verbose,n.steps))}finally{gD(a[0],e),gD(a[1],t)}},n.evaluateDataset=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.makeTestFunction(),e.abrupt("return",oD(this,t,n));case 2:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.checkNumSamples=function(e,t,n,r){var a;if(void 0===r&&(r="steps"),null!=n){if(a=null,null!=t)throw new XC("If "+r+" is set, batchSize must be null or undefined.Got batchSize = "+t)}else{if(null==e)throw new XC("Either the input data should have a defined shape, or "+r+" shoud be specified.");a=Array.isArray(e)?e[0].shape[0]:e.shape[0]}return a},n.execute=function(e,t){if(Array.isArray(t)&&0===t.length)throw new XC("`outputs` is an empty Array, which is not allowed.");var n=Array.isArray(t),r=n?t:[t],a=this.retrieveSymbolicTensors(r),i=new WA;if(e instanceof Fg&&(e=[e]),Array.isArray(e)){if(e.length!==this.inputs.length)throw new XC("The number of inputs provided ("+e.length+") does not match the number of inputs of this model ("+this.inputs.length+").");for(var o=0;o<this.inputs.length;++o)i.add(this.inputs[o],e[o])}else for(var s,u=tv(this.inputs);!(s=u()).done;){var l=s.value,c=e[l.name];if(null==c)throw new XC("No value is provided for the model's input "+l.name);i.add(l,c)}var p=GA(a,i);return n?p:p[0]},n.retrieveSymbolicTensors=function(e){for(var t,n=ZC(null,e.length),r=e.length,a=tv(this.layers);!(t=a()).done;){for(var i=t.value,o=Array.isArray(i.output)?i.output:[i.output],s=o.map((function(e){return e.name})),u=0;u<e.length;++u){var l=s.indexOf(e[u]);if(-1!==l&&(n[u]=o[l],r--),0===r)break}if(0===r)break}if(r>0){var c=[];throw n.forEach((function(t,n){null==t&&c.push(e[n])})),new XC("Cannot find SymbolicTensors for output name(s): "+JSON.stringify(c))}return n},n.predictLoop=function(e,t,n){var r=this;return void 0===t&&(t=32),void 0===n&&(n=!1),dx((function(){var a=r.checkNumSamples(e);if(n)throw new YC("Verbose predictLoop() is not implemented yet.");for(var i=pD(a,t),o=r.outputs.map((function(e){return[]})),s=function(t){dx((function(){var n=i[t][0],a=i[t][1],o=lD(e,n,a),s=[];if(Array.isArray(o))for(var u=0;u<o.length;++u)s.push({key:r.inputs[u],value:o[u]});else s.push({key:r.inputs[0],value:o});var l=new WA(s);return GA(r.outputs,l)})).forEach((function(e,t){return o[t].push(e)}))},u=0;u<i.length;++u)s(u);return eE(o.map((function(e){return $x(e,0)})))}))},n.predict=function(e,t){void 0===t&&(t={});var n=vD(e);wD(n,this.inputNames,this.feedInputShapes,!1);try{var r=null==t.batchSize?32:t.batchSize;return uD(r),this.predictLoop(n,r)}finally{gD(n,e)}},n.predictOnBatch=function(e){wD(e,this.inputNames,this.feedInputShapes,!0);var t=(Array.isArray(e)?e[0]:e).shape[0];return this.predictLoop(e,t)},n.standardizeUserDataXY=function(e,t,n,r){if(void 0===n&&(n=!0),null==this.optimizer_)throw new KC("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");for(var a=[],i=0;i<this.feedOutputShapes.length;++i){var o=this.feedOutputShapes[i];this.feedLossFns[i]===mA?a.push(o.slice(0,o.length-1).concat([1])):a.push(o)}if(function(e,t,n){var r=uE(e.map((function(e){return e.shape[0]})));r.sort();var a=uE(t.map((function(e){return e.shape[0]})));if(a.sort(),r.length>1)throw new XC("All input Tensors (x) should have the same number of samples. Got array shapes: "+JSON.stringify(e.map((function(e){return e.shape}))));if(a.length>1)throw new XC("All target Tensors (y) should have the same number of samples. Got array shapes: "+JSON.stringify(t.map((function(e){return e.shape}))));if(r.length>0&&a.length>0&&!dv(r,a))throw new XC("Input Tensors should have the same number of samples as target Tensors. Found "+r[0]+" input sample(s) and "+a[0]+" target sample(s).")}(e=xD(e,this.feedInputNames,this.feedInputShapes,!1,"input"),t=xD(t,this.feedOutputNames,a,!1,"target")),function(e,t,n){for(var r=[cA,vA,dA],a=0;a<e.length;++a){var i=e[a],o=t[a],s=n[a];if(null!=o){if(o===dA&&1===i.shape[i.shape.length-1])throw new XC("You are passing a target array of shape "+i.shape+" while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].");if(-1!==r.indexOf(o))for(var u=i.shape.slice(1),l=s.slice(1),c=0;c<u.length;++c){var p=u[c],h=l[c];if(null!=h&&p!==h)throw new XC("A target Tensor with shape "+i.shape+" was passed for an output of shape "+s+", while using a loss function that expects targets to have the same shape as the output.")}}}}(t,this.feedLossFns,this.feedOutputShapes),this.stateful&&null!=r&&r>0&&e[0].shape[0]%r!=0)throw new XC("In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size "+r+". Found: "+e[0].shape[0]+" sample(s).");return[e,t]},n.standardizeUserData=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n,r,a,i,o){var s,u,l,c,p,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===i&&(i=!0),s=this.standardizeUserDataXY(t,n,i,o),u=s[0],l=s[1],null==r){e.next=4;break}throw new Error("sample weight is not supported yet.");case 4:if(c=null,null==a){e.next=18;break}p=XA(a,this.outputNames),c=[],h=0;case 9:if(!(h<p.length)){e.next=18;break}return e.t0=c,e.next=13,YA(l[h],null,p[h]);case 13:e.t1=e.sent,e.t0.push.call(e.t0,e.t1);case 15:++h,e.next=9;break;case 18:return e.abrupt("return",[u,l,c]);case 19:case"end":return e.stop()}}),e,this)})));return function(t,n,r,a,i,o){return e.apply(this,arguments)}}(),n.testLoop=function(e,t,n,r,a){var i=this;return void 0===r&&(r=0),dx((function(){var o=i.checkNumSamples(t,n,a,"steps"),s=[];if(r>0)throw new YC("Verbose mode is not implemented yet.");if(null!=a)throw new YC("steps mode in testLoop() is not implemented yet");for(var u=pD(o,n),l=aI(jE(0,o)),c=0;c<u.length;++c){var p=u[c][0],h=u[c][1],f=KE(l,p,h-p),d=cD(t,f),m=e(d);if(0===c)for(var v=0;v<m.length;++v)s.push(_N(0));for(var g=0;g<m.length;++g){var y=m[g];s[g]=xx(s[g],Nx(h-p,y))}}for(var b=0;b<s.length;++b)s[b]=kx(s[b],o);return s}))},n.getDedupedMetricsNames=function(){for(var e=this.metricsNames,t=[],n=0;n<e.length;++n){var r=e[n],a=r;if($C(e,r)>1)a+="_"+$C(e.slice(0,n),r);t.push(a)}return t},n.makeTrainFunction=function(){var e=this;return function(t){var n=[],r=t.slice(0,e.inputs.length),a=t.slice(e.inputs.length,e.inputs.length+e.outputs.length),i=t.slice(e.inputs.length+e.outputs.length,e.inputs.length+2*e.outputs.length),o=[],s=e.collectedTrainableWeights.map((function(e){return e.read()}));return[e.optimizer_.minimize((function(){for(var t=[],s=0;s<e.inputs.length;++s)t.push({key:e.inputs[s],value:r[s]});for(var u,l=new WA(t),c=GA(e.outputs,l,{training:!0}),p=0;p<e.lossFunctions.length;++p){var h=(0,e.lossFunctions[p])(a[p],c[p]);null!=i[p]&&(h=ZA(h,i[p]));var f=Lk(h);n.push(f),u=0===p?h:xx(u,h)}for(var d=0;d<e.metricsTensors.length;++d){var m=void 0;if(e.outputs.length>1&&d<e.outputs.length)m=n[d];else{var v=e.metricsTensors[d][0],g=e.metricsTensors[d][1];m=Lk(v(a[g],c[g]))}vx(m),o.push(m)}return u=Lk(u),e.calculateLosses().forEach((function(e){u=xx(u,e)})),u}),!0,s)].concat(o)}},n.makeTestFunction=function(){var e=this;this.testFunction=function(t){return dx((function(){for(var n,r=[],a=t.slice(0,e.inputs.length),i=t.slice(e.inputs.length,e.inputs.length+e.outputs.length),o=[],s=0;s<e.inputs.length;++s)o.push({key:e.inputs[s],value:a[s]});for(var u=new WA(o),l=GA(e.outputs,u),c=0;c<e.lossFunctions.length;++c){var p=e.lossFunctions[c],h=Lk(p(i[c],l[c]));n=0===c?h:xx(n,h),r.push(n)}for(var f=0;f<e.metricsTensors.length;++f){var d=e.metricsTensors[f][0],m=e.metricsTensors[f][1],v=Lk(d(i[m],l[m]));r.push(v)}return r}))}},n.fit=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r={}),e.abrupt("return",dD(this,t,n,r));case 2:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),n.fitDataset=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",tD(this,t,n));case 1:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.trainOnBatch=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i,o,s,u,l,c,p,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.standardizeUserData(t,n);case 2:r=e.sent,a=r[0],i=r[1],o=this.makeTrainFunction(),s=o(a.concat(i)),u=[],l=tv(s);case 9:if((c=l()).done){e.next=17;break}return p=c.value,e.next=13,p.data();case 13:h=e.sent,u.push(h[0]);case 15:e.next=9;break;case 17:return mx(s),e.abrupt("return",eE(u));case 19:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.getNamedWeights=function(e){for(var t=[],n=null!=e&&e.trainableOnly,r=n?this.trainableWeights:this.weights,a=this.getWeights(n),i=0;i<r.length;++i)n&&!r[i].trainable||t.push({name:r[i].originalName,tensor:a[i]});return t},n.dispose=function(){var t=e.prototype.dispose.call(this);if(0===t.refCountAfterDispose&&null!=this.optimizer&&this.isOptimizerOwned){var n=fx().numTensors;this.optimizer_.dispose(),t.numDisposedVariables+=n-fx().numTensors}return t},n.getLossIdentifiers=function(){var e;if("string"==typeof this.loss)e=nE(this.loss);else if(Array.isArray(this.loss)){for(var t,n=tv(this.loss);!(t=n()).done;){if("string"!=typeof t.value)throw new Error("Serialization of non-string loss is not supported.")}e=this.loss.map((function(e){return nE(e)}))}else{var r=Object.keys(this.loss);e={};for(var a=this.loss,i=0,o=r;i<o.length;i++){var s=o[i];if("string"!=typeof a[s])throw new Error("Serialization of non-string loss is not supported.");e[s]=nE(a[s])}}return e},n.getMetricIdentifiers=function(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return[nE(FA(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map((function(e){return nE(FA(e))}));var e={};for(var t in this.metrics)e[t]=nE(FA(this.metrics[t]));return e},n.getTrainingConfig=function(){return{loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}}},n.loadTrainingConfig=function(e){if(null!=e.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=e.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=e.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");var t,n,r=uA(BA(e.optimizer_config));if("string"==typeof e.loss)t=rE(e.loss);else if(Array.isArray(e.loss))t=e.loss.map((function(e){return rE(e)}));else if(null!=e.loss)for(var a in t={},e.loss)t[a]=rE(e.loss[a]);if(Array.isArray(e.metrics))n=e.metrics.map((function(e){return rE(e)}));else if(null!=e.metrics)for(var i in n={},e.metrics)n[i]=rE(e.metrics[i]);this.compile({loss:t,metrics:n,optimizer:r})},n.save=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i,o,s,u,l,c,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=9;break}if(0!==(r=Iy(t)).length){e.next=6;break}throw new XC("Cannot find any save handlers for URL '"+t+"'");case 6:if(!(r.length>1)){e.next=8;break}throw new XC("Found more than one ("+r.length+") save handlers for URL '"+t+"'");case 8:t=r[0];case 9:if(null!=t.save){e.next=11;break}throw new XC("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");case 11:return e.next=13,py(this.getNamedWeights(n));case 13:if(a=e.sent,!1,null,i=this.toJSON(null,!1),o={modelTopology:i,format:"layers-model",generatedBy:"TensorFlow.js tfjs-layers v2.8.1",convertedBy:null},!(null!=n&&n.includeOptimizer)||null==this.optimizer){e.next=34;break}return o.trainingConfig=this.getTrainingConfig(),u="optimizer",e.t0=Nb,e.next=25,this.optimizer.getWeights();case 25:return e.t1=e.sent,e.t2=u,e.next=29,e.t0.encodeWeights.call(e.t0,e.t1,e.t2);case 29:l=e.sent,c=l.data,p=l.specs,(s=a.specs).push.apply(s,p),a.data=by([a.data,c]);case 34:return null!=this.userDefinedMetadata&&(!0,_A(this.userDefinedMetadata,this.name,!0),o.userDefinedMetadata=this.userDefinedMetadata),o.weightData=a.data,o.weightSpecs=a.specs,e.abrupt("return",t.save(o));case 38:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.setUserDefinedMetadata=function(e){_A(e,this.name),this.userDefinedMetadata=e},n.getUserDefinedMetadata=function(){return this.userDefinedMetadata},Hm(t,[{key:"stopTraining",set:function(e){this.stopTraining_=e},get:function(){return this.stopTraining_}},{key:"optimizer",get:function(){return this.optimizer_},set:function(e){this.optimizer_!==e&&(this.optimizer_=e,this.isOptimizerOwned=!1)}}]),t}(function(e){function t(n){var r;if((r=e.call(this,{})||this).containerNodes=new Set,r.name=n.name,null==r.name){var a=r.getClassName().toLowerCase();r.name=_R(a)}if(r.supportsMasking=!1,r.trainable_=!0,Array.isArray(n.inputs)?r.inputs=n.inputs.slice():r.inputs=[n.inputs],Array.isArray(n.outputs)?r.outputs=n.outputs.slice():r.outputs=[n.outputs],uE(r.inputs).length!==r.inputs.length)throw new XC("The list of inputs passed to the model is redundant. All inputs should only appear once. Found: "+r.inputs.map((function(e){return e.name})));uE(r.outputs).length!==r.outputs.length&&console.warn("The list of outputs passed to the model is redundant. All outputs should only appear once. Found: "+r.outputs.map((function(e){return e.name}))),r.inputLayers=[],r.inputLayersNodeIndices=[],r.inputLayersTensorIndices=[],r.outputLayers=[],r.outputLayersNodeIndices=[],r.outputLayersTensorIndices=[],r.layers=[],r.internalContainerRefs=[];for(var i,o=tv(r.outputs);!(i=o()).done;){var s=i.value,u=s.sourceLayer,l=s.nodeIndex,c=s.tensorIndex;r.outputLayers.push(u),r.outputLayersNodeIndices.push(l),r.outputLayersTensorIndices.push(c)}for(var p,h=tv(r.inputs);!(p=h()).done;){var f=p.value,d=f.sourceLayer,m=f.nodeIndex,v=f.tensorIndex;QC(0===m,"input layer has >1 nodes"),QC(0===v,"input layer has >1 tensors"),r.inputLayers.push(d),r.inputLayersNodeIndices.push(m),r.inputLayersTensorIndices.push(v)}r.inputNames=[],r.outputNames=[],r.feedInputShapes=[],r.feedInputNames=[],r.feedOutputNames=[];for(var g=0;g<r.inputLayers.length;g++){var y=r.inputLayers[g];if(!(y instanceof YR))throw new TypeError("Input layers to a LayersModel must be InputLayer objects. Received inputs: "+n.inputs+". Input "+g+" (0-based) originates from layer type "+y.getClassName()+".");r.inputNames.push(y.name),r.feedInputShapes.push(y.batchInputShape),r.feedInputNames.push(y.name)}for(var b,x=tv(r.outputLayers);!(b=x()).done;){var w=b.value;r.outputNames.push(w.name)}r.internalInputShapes=r.inputs.map((function(e){return e.shape})),r.internalOutputShapes=r.outputs.map((function(e){return e.shape}));for(var k,N={},I={},S={},T={},C={},E=[],R=function e(n,a,i,o,s,u){null!=o&&null!=s&&null!=u||(o=n.sourceLayer,s=n.nodeIndex,u=n.tensorIndex);var l=o.inboundNodes[s];if(-1!==i.indexOf(l))throw new KC("The tensor "+n.name+' at layer "'+o.name+'" is part of a cycle.');if(-1===a.indexOf(l)){r.containerNodes.add(t.nodeKey(o,s)),o.id in C||(C[o.id]=Object.keys(C).length),-1===i.indexOf(l)&&i.push(l);for(var c=l.inboundLayers.length,p=0;p<c;p++){e(l.inputTensors[p],a,i,l.inboundLayers[p],l.nodeIndices[p],l.tensorIndices[p])}for(a.push(l);i.indexOf(l)>=0;)i.splice(i.indexOf(l),1);E.push(l)}},A=[],D=[],F=tv(r.outputs);!(k=F()).done;){R(k.value,A,D)}for(var _,O=tv(E.slice().reverse());!(_=O()).done;){var M=_.value;I[M.id]=M,M.id in N||(N[M.id]=0);var L=N[M.id],z=null==S[M.outboundLayer.id]?0:S[M.outboundLayer.id];L=Math.max(L,z),S[M.outboundLayer.id]=L,T[M.outboundLayer.id]=M.outboundLayer,N[M.id]=L;for(var P=0;P<M.inboundLayers.length;P++){var B=M.inboundLayers[P],W=M.nodeIndices[P],V=B.inboundNodes[W],U=null==N[V.id]?0:N[V.id];N[V.id]=Math.max(L+1,U),I[V.id]=V}}var G={};for(var j in N){var H=N[j];H in G||(G[H]=[]),G[H].push(I[j])}var q={};for(var K in S){var X=S[K];X in q||(q[X]=[]),q[X].push(T[K])}var Y=Object.keys(q).map((function(e){return parseInt(e,10)})).sort(sE);r.layers=[];for(var J,Z=tv(Y);!(J=Z()).done;){var Q=q[J.value];Q.sort((function(e,t){var n=C[e.id],r=C[t.id];return n<r?-1:n>r?1:0}));for(var $,ee=tv(Q);!($=ee()).done;){var te=$.value;te instanceof t&&r.internalContainerRefs.push(te),r.layers.push(te)}}r.layersByDepth=q,Y=Object.keys(G).map((function(e){return parseInt(e,10)})).sort(sE);for(var ne,re=r.inputs.slice(),ae=[],ie=tv(Y);!(ne=ie()).done;)for(var oe,se=tv(G[ne.value]);!(oe=se()).done;){var ue=oe.value,le=ue.outboundLayer;if(null!=le){for(var ce,pe=tv(ue.inputTensors);!(ce=pe()).done;){var he=ce.value;if(-1===re.indexOf(he))throw new KC("Graph disconnected: cannot obtain value for tensor "+he+' at layer "'+le.name+'". The following previous layers were accessed without issue: '+ae)}for(var fe,de=tv(ue.outputTensors);!(fe=de()).done;){var me=fe.value;re.push(me)}ae.push(le.name)}}r.nodesByDepth=G;for(var ve,ge=r.layers.map((function(e){return e.name})),ye=function(){var e=ve.value,t=ge.filter((function(t){return t===e})).length;if(1!==t)throw new KC('The name "'+e+'" is used '+t+" times in the model. All layer names should be unique. Layer names: "+JSON.stringify(ge))},be=tv(ge);!(ve=be()).done;)ye();return r.outboundNodes=[],r.inboundNodes=[],new HR({outboundLayer:Qm(r),inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:r.inputs,outputTensors:r.outputs,inputMasks:r.inputs.map((function(e){return null})),outputMasks:r.outputs.map((function(e){return null})),inputShapes:r.inputs.map((function(e){return e.shape})),outputShapes:r.outputs.map((function(e){return e.shape}))}),r.built=!0,r._refCount=1,r}qm(t,e);var n=t.prototype;return n.assertNotDisposed=function(){if(0===this._refCount)throw new Error("Container '"+this.name+"' is already disposed.")},n.dispose=function(){this.assertNotDisposed();var e={refCountAfterDispose:null,numDisposedVariables:0};if(0==--this._refCount){for(var t,n=tv(this.layers);!(t=n()).done;){var r=t.value;e.numDisposedVariables+=r.dispose().numDisposedVariables}for(var a,i=tv(this.internalContainerRefs);!(a=i()).done;){var o=a.value;e.numDisposedVariables+=o.dispose().numDisposedVariables}}return e.refCountAfterDispose=this._refCount,e},n.loadWeights=function(e,t){void 0===t&&(t=!0);for(var n,r={},a=0,i=tv(this.layers);!(n=i()).done;)for(var o,s=tv(n.value.weights);!(o=s()).done;){var u=o.value;if(null!=r[u.originalName])throw new XC("Duplicate weight name: "+u.originalName);r[u.originalName]=u,a++}var l=[];for(var c in e){var p=c;if(null==r[c]){var h=c.split("/");p=h.slice(0,-2).concat([h[h.length-1]]).join("/")}if(null!=r[p])l.push([r[p],e[c]]);else if(t)throw new XC("Provided weight data has no target variable: "+c);delete r[p]}if(t){var f=[];for(var d in r)f.push(d);if(f.length>0)throw new XC(f.length+" of "+a+" weights are not set: "+f)}VR(l)},n.updatedConfig=function(){var e=this.getConfig(),t={};return t.className=this.getClassName(),t.config=e,t.kerasVersion="tfjs-layers 2.8.1",t.backend="TensorFlow.js",t},n.toJSON=function(e,t){void 0===t&&(t=!0);var n=function e(t,n){if(null==t)return null;if("string"==typeof t)return nE(t);if("number"==typeof t||"boolean"==typeof t)return t;if(t instanceof Array){for(var r=[],a=t.length,i=0;i<a;++i){var o=t[i];PA(n,i,o)?r.push(o):r.push(e(o,n))}return r}for(var s={},u=0,l=Object.keys(t);u<l.length;u++){var c=l[u],p=t[c],h=nE(c);s[h]="name"!==c&&"className"!==c||"string"!=typeof p?e(p,c):p}return s}(this.updatedConfig());return t?JSON.stringify(n):n},n.call=function(e,t){var n=this;return dx((function(){e=tE(e);for(var r=new WA,a=0;a<n.inputs.length;++a)r.add(n.inputs[a],e[a]);return GA(n.outputs,r,t)}))},n.computeMask=function(e,t){var n=this;return dx((function(){var r;return e=tE(e),r=null==t?ZC(null,e.length):tE(t),n.runInternalGraph(e,r)[1]}))},n.computeOutputShape=function(e){var t=MR(e);if(t.length!==this.inputLayers.length)throw new XC("Invalid inputShape argument "+e+": model has "+this.inputLayers.length+" tensor inputs.");for(var n={},r=0;r<t.length;r++){var a=this.inputLayers[r],i=t[r];n[a.name+"_0_0"]=i}var o=Object.keys(this.nodesByDepth).map((function(e){return parseInt(e,10)})).sort(sE);if(o.length>1)for(var s,u=tv(o);!(s=u()).done;)for(var l,c=s.value,p=tv(this.nodesByDepth[c]);!(l=p()).done;){var h=l.value,f=h.outboundLayer;if(-1===this.inputLayers.map((function(e){return e.id})).indexOf(f.id)){for(var d=[],m=0;m<h.inboundLayers.length;m++){var v=h.inboundLayers[m],g=h.nodeIndices[m],y=h.tensorIndices[m],b=n[v.name+"_"+g+"_"+y];d.push(b)}for(var x=MR(f.computeOutputShape(eE(d))),w=f.inboundNodes.indexOf(h),k=0;k<x.length;k++){n[f.name+"_"+w+"_"+k]=x[k]}}}for(var N=[],I=[],S=0;S<this.outputLayers.length;S++){var T=this.outputLayers[S],C=this.outputLayersNodeIndices[S],E=this.outputLayersTensorIndices[S],R=T.name+"_"+C+"_"+E;I.push(R)}for(var A=0;A<I.length;A++){var D=I[A];QC(D in n),N.push(n[D])}return eE(N)},n.runInternalGraph=function(e,t){null==t&&(t=ZC(null,e.length));for(var n={},r=0;r<this.inputs.length;++r){var a=this.inputs[r],i=e[r],o=t[r];n[a.id]=[i,o]}for(var s,u=tv(Object.keys(this.nodesByDepth).map((function(e){return parseInt(e,10)})).sort(sE));!(s=u()).done;)for(var l,c=s.value,p=tv(this.nodesByDepth[c]);!(l=p()).done;){for(var h,f=l.value,d=f.outboundLayer,m=f.inputTensors,v=f.outputTensors,g=new Array,y=tv(m);!(h=y()).done;){var b=h.value;b.id in n&&g.push(n[b.id])}if(g.length===m.length){var x={},w=void 0,k=void 0,N=void 0,I=void 0;if(null!=f.callArgs&&(x=f.callArgs),1===g.length){var S=g[0],T=S[0],C=S[1];null==x.mask&&(x.mask=C),N=tE(d.call(T,x)),I=tE(d.computeMask(T,C)),w=[T],k=[C]}else w=g.map((function(e){return e[0]})),k=g.map((function(e){return e[1]})),null==x.mask&&(x.mask=k),N=tE(d.call(w,x)),I=tE(d.computeMask(w,k));if(d.activityRegularizer)throw new YC("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(var E=0;E<v.length;++E){var R=v[E],A=N[E],D=I[E];n[R.id]=[A,D]}}}for(var F,_=[],O=[],M=[],L=tv(this.outputs);!(F=L()).done;){var z=F.value;QC(z.id in n,"Could not compute output "+z.name+" : "+z.id);var P=n[z.id],B=P[0],W=P[1];M.push(B.shape),_.push(B),O.push(W)}return[_,O,M]},n.buildNodeConversionMap=function(e){for(var n,r,a={},i=tv(this.layers);!(r=i()).done;){var o=r.value;n=o instanceof t?1:0;for(var s=0;s<o.inboundNodes.length;s++){var u=t.nodeKey(o,s);this.containerNodes.has(u)&&(a[u]=n,n+=1)}}return a},n.getLayer=function(e,t){if(null!=t){if(this.layers.length<=t)throw new XC("Was asked to retrieve layer at index "+t+", but model only has "+this.layers.length+" layer(s).");return this.layers[t]}if(null==e)throw new XC("Provide either a layer name or layer index");for(var n,r=tv(this.layers);!(n=r()).done;){var a=n.value;if(a.name===e)return a}throw new XC("No such layer: "+e)},n.calculateLosses=function(){var e=this;return dx((function(){for(var n,r=[],a=tv(e.layers);!(n=a()).done;)for(var i=n.value,o=0;o<i.inboundNodes.length;++o){var s=t.nodeKey(i,o);e.containerNodes.has(s)&&r.push.apply(r,i.calculateLosses())}return r}))},n.getConfig=function(){for(var e,n={name:this.name},r=this.buildNodeConversionMap(this.layers),a=[],i=tv(this.layers);!(e=i()).done;){for(var o=e.value,s=o.getClassName(),u=o.getConfig(),l=[],c=0;c<o.inboundNodes.length;c++){var p=o.inboundNodes[c],h=t.nodeKey(o,c),f={};if(this.containerNodes.has(h)){if(p.callArgs)try{JSON.stringify(p.callArgs),f=p.callArgs}catch(e){console.warn("Layer "+o.name+" was passed non-serializable keyword arguments: "+p.callArgs+". They will not be included in the serialized model (and thus will be missing at deserialization time)."),f={}}if(p.inboundLayers.length>0){for(var d=[],m=0;m<p.inboundLayers.length;m++){var v=p.inboundLayers[m],g=p.nodeIndices[m],y=p.tensorIndices[m],b=r[t.nodeKey(v,g)];null==b&&(b=0),d.push([v.name,b,y,f])}l.push(d)}}}var x={};x.name=o.name,x.className=s,x.config=u,x.inboundNodes=l,a.push(x)}n.layers=a;for(var w=[],k=0;k<this.inputLayers.length;k++){var N=this.inputLayers[k],I=this.inputLayersNodeIndices[k],S=t.nodeKey(N,I);if(this.containerNodes.has(S)){var T=r[S];null==T&&(T=0);var C=this.inputLayersTensorIndices[k];w.push([N.name,T,C])}}n.inputLayers=w;for(var E=[],R=0;R<this.outputLayers.length;R++){var A=this.outputLayers[R],D=this.outputLayersNodeIndices[R],F=t.nodeKey(A,D);if(this.containerNodes.has(F)){var _=r[F];null==_&&(_=0);var O=this.outputLayersTensorIndices[R];E.push([A.name,_,O])}}return n.outputLayers=E,n},t.fromConfig=function(e,t,n,r){void 0===n&&(n={}),void 0===r&&(r=!1);var a={},i={};function o(e,t){e.name in i?i[e.name].push(t):i[e.name]=[t]}function s(e,t){for(var n,r,i=[],s=tv(t);!(r=s()).done;){var u=r.value,l=u[0],c=u[1],p=u[2];if(n=null==u[3]?{}:u[3],!(l in a))return void o(e,t);var h=a[l];if(h.inboundNodes.length<=c)return void o(e,t);var f=h.inboundNodes[c];i.push(f.outputTensors[p])}i.length>0&&e.apply(eE(i),n)}function u(e){var n=e.name,i=uA(e,null!=t.customObjects?t.customObjects:{});i.setFastWeightInitDuringBuild(r),a[n]=i,e.inboundNodes.forEach((function(e){if(!(e instanceof Array))throw new XC("Corrupted configuration, expected array for nodeData: "+e);o(i,e)}))}for(var l,c=t.name,p=t.layers,h=tv(p);!(l=h()).done;){u(l.value)}for(;!lE(i);)for(var f,d=tv(p);!(f=d()).done;){var m=f.value,v=a[m.name];if(v.name in i){var g=i[v.name];delete i[v.name];for(var y,b=tv(g);!(y=b()).done;){s(v,y.value)}}}for(var x,w=[],k=[],N=tv(t.inputLayers);!(x=N()).done;){var I=x.value,S=I[0],T=I[1],C=I[2];QC(S in a);var E=a[S].inboundNodes[T].outputTensors;w.push(E[C])}for(var R,A=tv(t.outputLayers);!(R=A()).done;){var D=R.value,F=D[0],_=D[1],O=D[2];QC(F in a);var M=a[F].inboundNodes[_].outputTensors;k.push(M[O])}return new e({inputs:w,outputs:k,name:c})},n.resetStates=function(){var e=this;dx((function(){e.layers.forEach((function(e){e.stateful&&e.resetStates()}))}))},Hm(t,[{key:"trainable",get:function(){return this.trainable_},set:function(e){this.layers.forEach((function(t){t._trainableWeights.forEach((function(t){return t.trainable=e}))})),this.trainable_=e}},{key:"trainableWeights",get:function(){if(this._trainableWeights.length>0)throw new XC("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return[];for(var e,t=[],n=tv(this.layers);!(e=n()).done;){var r=e.value;t=t.concat(r.trainableWeights)}return t}},{key:"nonTrainableWeights",get:function(){for(var e,t=[],n=tv(this.layers);!(e=n()).done;){var r=e.value;t.push.apply(t,r.nonTrainableWeights)}if(!this.trainable){for(var a,i=[],o=tv(this.layers);!(a=o()).done;){var s=a.value;i.push.apply(i,s.trainableWeights)}return i.concat(t)}return t}},{key:"weights",get:function(){return this.trainableWeights.concat(this.nonTrainableWeights)}},{key:"stateful",get:function(){if(this._stateful)throw new XC("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(var e,t=tv(this.layers);!(e=t()).done;){if(e.value.stateful)return!0}return!1}}]),t}(KR));kD.className="Model",ax(kD);var ND=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t}(kD);function ID(){return(ID=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i,o,s,u,l,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("modelTopology"in t||(t={modelTopology:t}),null!=(r=(t=t).modelTopology).model_config&&(r=r.model_config),a=BA(r),i=uA(a,n),null==t.weightsManifest){e.next=14;break}return e.next=9,hb(t.weightsManifest,t.pathPrefix,i.weights.map((function(e){return e.originalName})));case 9:for(o=e.sent,s={},u=tv(i.weights);!(l=u()).done;)c=l.value,s[c.originalName]=o[c.originalName];i.loadWeights(s),mx(o);case 14:return e.abrupt("return",i);case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function SD(){return(SD=Gm(regeneratorRuntime.mark((function e(t,n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n&&(n={}),"string"!=typeof t){e.next=10;break}if(0!==(r=Sy(t,n)).length){e.next=7;break}r.push(xb(t,n)),e.next=9;break;case 7:if(!(r.length>1)){e.next=9;break}throw new XC("Found more than one ("+r.length+") load handlers for URL '"+t+"'");case 9:t=r[0];case 10:return e.abrupt("return",TD(t,void 0,n));case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function TD(e,t,n){return CD.apply(this,arguments)}function CD(){return(CD=Gm(regeneratorRuntime.mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==r&&(r={}),null!=t.load){e.next=3;break}throw new XC("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");case 3:return e.next=5,t.load();case 5:if(a=e.sent,null!=(i=a.modelTopology).model_config&&(i=i.model_config),o=null==r.strict||r.strict,s=null!=a.weightData&&null!=a.weightSpecs&&o,u=uA(BA(i),n,s),null!=(l=a.trainingConfig)&&u.loadTrainingConfig(l),null!=a.userDefinedMetadata&&u.setUserDefinedMetadata(a.userDefinedMetadata),null==a.weightData){e.next=24;break}if(null!=a.weightSpecs){e.next=17;break}throw new XC("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");case 17:if(c=ED(a.weightData,a.weightSpecs),p=c.modelWeights,h=c.optimizerWeights,u.loadWeights(p,o),!(null!=u.optimizer&&h.length>0)){e.next=22;break}return e.next=22,u.optimizer.setWeights(h);case 22:mx(p),mx(h.map((function(e){return e.tensor})));case 24:return e.abrupt("return",u);case 25:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ED(e,t){var n=fy(e,t),r={},a=[];return t.forEach((function(e){"optimizer"===e.group?a.push({name:e.name,tensor:n[e.name]}):r[e.name]=n[e.name]})),{modelWeights:r,optimizerWeights:a}}ND.className="Functional",ax(ND);var RD=function(e){function t(t){var n;if(t=t||{},(n=e.call(this,{inputs:[],outputs:[]})||this).trainable=!0,n.built=!1,n.name=null!=t.name?t.name:_R("sequential_"),null!=t.layers)for(var r,a=tv(t.layers);!(r=a()).done;){var i=r.value;n.add(i)}return n}qm(t,e);var n=t.prototype;return n.checkShape=function(e){if(e.inboundNodes[0].outputTensors[0].shape.some((function(e){return e<0})))throw new XC("Negative dimension size caused by adding layer "+e.name+" with input shape ["+e.inboundNodes[0].inputTensors[0].shape+"]")},n.add=function(e){var n,r=e instanceof t||e instanceof kD;if(r){if(1!==(n=e).outputs.length)throw new XC("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==n.inputs.length)throw new XC("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.")}if(0===this.outputs.length){if(0===e.inboundNodes.length){if(null==e.batchInputShape)throw new XC("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");var a=JR({batchShape:e.batchInputShape,dtype:e.dtype,name:e.name+"_input"});e.apply(a)}if(r)this.outputs=n.outputs,this.inputs=n.inputs;else{if(1!==e.inboundNodes.length)throw new XC("A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer "+e.name+" which has "+e.inboundNodes.length+" pre-existing inbound connections.");if(1!==e.inboundNodes[0].outputTensors.length)throw new XC("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[e.inboundNodes[0].outputTensors[0]],this.inputs=function e(t,n,r){if((null==n||null!=r&&r>0)&&(n=t.sourceLayer,r=t.nodeIndex),0===n.inboundNodes.length)return[t];var a=n.inboundNodes[r];if(0===a.inboundLayers.length)return a.inputTensors;for(var i=[],o=0;o<a.inboundLayers.length;o++)for(var s,u=tv(e(a.inputTensors[o],a.inboundLayers[o],a.nodeIndices[o]));!(s=u()).done;){var l=s.value;-1===i.indexOf(l)&&i.push(l)}return i}(this.outputs[0])}this.inboundNodes=[],new HR({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:ZC(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map((function(e){return e.shape})),outputShapes:this.outputs[0].shape})}else{var i=e.apply(this.outputs[0]);if(Array.isArray(i))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(e),this.outputs=[i],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}this.layers.push(e),this.built=!1},n.pop=function(){if(0===this.layers.length)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),0===this.layers.length)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else{var e=this.layers.length-1;this.layers[e].outboundNodes=[],this.outputs=[this.layers[e].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape]}},n.call=function(e,t){return null==this.model&&this.build(),this.model.call(e,t)},n.build=function(e){if(zR(e),0===this.inputs.length||0===this.outputs.length)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new kD({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0},n.countParams=function(){return this.built||this.build(),e.prototype.countParams.call(this)},n.summary=function(t,n,r){void 0===r&&(r=console.log),this.built||this.build(),e.prototype.summary.call(this,t,n,r)},n.setWeights=function(e){null==this.model&&this.build(),this.model.setWeights(e)},n.evaluate=function(e,t,n){if(void 0===n&&(n={}),!this.built)throw new KC("The model needs to be compiled before being used.");return this.model.evaluate(e,t,n)},n.evaluateDataset=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.built){e.next=2;break}throw new KC("The model needs to be compiled before being used.");case 2:return e.abrupt("return",this.model.evaluateDataset(t,n));case 3:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.predict=function(e,t){return void 0===t&&(t={}),null==this.model&&this.build(),this.model.predict(e,t)},n.predictOnBatch=function(e){return null==this.model&&this.build(),this.model.predictOnBatch(e)},n.compile=function(e){this.build(),this.model.compile(e),this.optimizer_=this.model.optimizer,this.isOptimizerOwned=this.model.isOptimizerOwned,this.loss=this.model.loss,this.metrics=this.model.metrics,this.metricsTensors=this.model.metricsTensors,this.metricsNames=this.model.metricsNames},n.fit=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===r&&(r={}),this.built){e.next=3;break}throw new KC("The model needs to be compiled before being used.");case 3:return e.abrupt("return",this.model.fit(t,n,r));case 4:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),n.fitDataset=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.built){e.next=2;break}throw new KC("The model needs to be compiled before being used.");case 2:return e.abrupt("return",this.model.fitDataset(t,n));case 3:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.trainOnBatch=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.model.trainOnBatch(t,n));case 1:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.fromConfig=function(e,n,r,a){var i;void 0===r&&(r={}),void 0===a&&(a=!1);var o={};if(n instanceof Array){if(null==n[0].className||"Merge"===n[0].className)throw new XC("Legacy serialization format not supported yet.");i=n}else lv(null!=n.layers,(function(){return"When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field."})),i=n.layers,delete n.layers,o=n;var s=new e(o);if(!(s instanceof t))throw new YC("Sequential.fromConfig called on non-Sequential input: "+s);for(var u,l=tv(i);!(u=l()).done;){var c=uA(u.value,void 0,a);a&&c.setFastWeightInitDuringBuild(!0),s.add(c)}return s},n.getConfig=function(){for(var e,t=[],n=tv(this.layers);!(e=n()).done;){var r=e.value,a={};a.className=r.getClassName(),a.config=r.getConfig(),t.push(a)}return{name:this.name,layers:t}},Hm(t,[{key:"optimizer",get:function(){return null==this.model?void 0:this.model.optimizer},set:function(e){this.model.optimizer=e}},{key:"stopTraining",set:function(e){if(null==this.model)throw new XC("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=e},get:function(){if(null==this.model)throw new XC("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining}}]),t}(kD);function AD(e){return JR(e)}RD.className="Sequential",ax(RD);var DD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.getConfig=function(){return{}},t}(nx),FD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e,t){return void 0===t&&(t=1),function(e,t){if(void 0===t&&(t=1),1!==t)throw new YC("Support for alpha values other than 1 ("+t+") is not implemented yet.");return Ww(e)}(e,t)},t}(DD);FD.className="elu",ax(FD);var _D=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e){return ON(e)},t}(DD);_D.className="selu",ax(_D);var OD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e){return IN(e)},t}(DD);OD.className="relu",ax(OD);var MD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e){return dx((function(){return Pk(6,IN(e))}))},t}(DD);MD.className="relu6",ax(MD);var LD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e){return e},t}(DD);LD.className="linear",ax(LD);var zD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e){return ew(e)},t}(DD);zD.className="sigmoid",ax(zD);var PD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e){return function(e){return dx((function(){var t=xx(.5,Nx(.2,e));return hw(t,0,1)}))}(e)},t}(DD);PD.className="hardSigmoid",ax(PD);var BD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e){return fk(e)},t}(DD);BD.className="softplus",ax(BD);var WD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e){return function(e){return dx((function(){return kx(e,Ix(e).add(1))}))}(e)},t}(DD);WD.className="softsign",ax(WD);var VD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e){return nw(e)},t}(DD);VD.className="tanh",ax(VD);var UD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e,t){return void 0===t&&(t=-1),HN(e,t)},t}(DD);UD.className="softmax",ax(UD);var GD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e,t){return void 0===t&&(t=-1),yk(e,t)},t}(DD);GD.className="logSoftmax",ax(GD);var jD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e,t){return void 0===t&&(t=1),dx((function(){return ew(e.mul(t)).mul(e)}))},t}(DD);function HD(e){return e.getClassName()}function qD(e,t){return void 0===t&&(t={}),oE(e,rx.getMap().classNameMap,t,"activation")}function KD(e){if(null==e){var t={className:"linear",config:{}};return qD(t)}if("string"==typeof e){var n={};return n.className=e,n.config={},qD(n)}return e instanceof DD?e:qD(e)}function XD(e){if(null!=e&&"object"!=typeof e)throw new Error("Argument to L1L2 regularizer's constructor is expected to be an object, but received: "+e)}jD.className="swish",ax(jD);var YD=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t}(nx),JD=function(e){function t(t){var n;return n=e.call(this)||this,XD(t),n.l1=null==t||null==t.l1?.01:t.l1,n.l2=null==t||null==t.l2?.01:t.l2,n.hasL1=0!==n.l1,n.hasL2=0!==n.l2,n}qm(t,e);var n=t.prototype;return n.apply=function(e){var t=this;return dx((function(){var n=qk([1]);return t.hasL1&&(n=xx(n,gk(Nx(t.l1,Ix(e))))),t.hasL2&&(n=xx(n,gk(Nx(t.l2,nR(e))))),n.asScalar()}))},n.getConfig=function(){return{l1:this.l1,l2:this.l2}},t.fromConfig=function(e,t){return new e({l1:t.l1,l2:t.l2})},t}(YD);JD.className="L1L2",ax(JD);var ZD={l1l2:"L1L2"};function QD(e){return iE(e)}function $D(e,t){return void 0===t&&(t={}),oE(e,rx.getMap().classNameMap,t,"regularizer")}function eF(e){return null==e?null:"string"==typeof e?$D({className:e in ZD?ZD[e]:e,config:{}}):e instanceof YD?e:$D(e)}var tF=function(e){function t(t){var n;return(n=e.call(this,null==t?{}:t)||this).supportsMasking=!0,null!=t&&(n.maxValue=t.maxValue),n}qm(t,e);var n=t.prototype;return n.call=function(e,t){e=LR(e);var n=IN(e);return null!=this.maxValue&&(n=hw(n,0,this.maxValue)),n},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t={maxValue:this.maxValue},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);tF.className="ReLU",ax(tF);var nF=function(e){function t(t){var n;return(n=e.call(this,null==t?{}:t)||this).DEFAULT_ALPHA=.3,null==t&&(t={}),n.alpha=null==t.alpha?n.DEFAULT_ALPHA:t.alpha,n}qm(t,e);var n=t.prototype;return n.call=function(e,t){var n=LR(e);return nk(n,this.alpha)},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t={alpha:this.alpha},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);nF.className="LeakyReLU",ax(nF);var rF=function(e){function t(t){var n;if((n=e.call(this,null==t?{}:t)||this).DEFAULT_ALPHA_INITIALIZER="zeros",null==t&&(t={}),n.supportsMasking=!0,n.alphaInitializer=ER(t.alphaInitializer||n.DEFAULT_ALPHA_INITIALIZER),n.alphaRegularizer=eF(t.alphaRegularizer),n.alphaConstraint=NE(t.alphaConstraint),null==t.sharedAxes)n.sharedAxes=null;else if(Array.isArray(t.sharedAxes))n.sharedAxes=t.sharedAxes;else{if("number"!=typeof t.sharedAxes)throw new XC("Expected sharedAxes to be a number or an array of numbers, but got "+t.sharedAxes);n.sharedAxes=[t.sharedAxes]}return n}qm(t,e);var n=t.prototype;return n.build=function(e){var t=(e=zR(e)).slice(1);if(null!=this.sharedAxes)for(var n,r=tv(this.sharedAxes);!(n=r()).done;){t[n.value-1]=1}this.alpha=this.addWeight("alpha",t,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);var a={};if(null!=this.sharedAxes)for(var i=1;i<e.length;++i)a[i]=e[i];this.inputSpec=[new UR({ndim:e.length,axes:a})],this.built=!0},n.call=function(e,t){return e=LR(e),aN(e,this.alpha.read())},n.getConfig=function(){var t={alphaInitializer:CR(this.alphaInitializer),alphaRegularizer:QD(this.alphaRegularizer),alphaConstraint:wE(this.alphaConstraint),sharedAxes:this.sharedAxes},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);rF.className="PReLU",ax(rF);var aF=function(e){function t(t){var n;if((n=e.call(this,null==t?{}:t)||this).DEFAULT_ALPHA=1,null==t&&(t={}),null!=t.alpha&&t.alpha!==n.DEFAULT_ALPHA)throw new YC("Non-default alpha value ("+t.alpha+") is not supported by the ELU layer yet.");return n.alpha=null==t.alpha?n.DEFAULT_ALPHA:t.alpha,n}qm(t,e);var n=t.prototype;return n.call=function(e,t){var n=LR(e);return Ww(n)},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t={alpha:this.alpha},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);aF.className="ELU",ax(aF);var iF=function(e){function t(t){var n;return(n=e.call(this,null==t?{}:t)||this).DEFAULT_THETA=1,null==t&&(t={}),n.theta=null==t.theta?n.DEFAULT_THETA:t.theta,n}qm(t,e);var n=t.prototype;return n.call=function(e,t){var n=LR(e);return n.mul(HE(n.greater(this.theta),"float32"))},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t={theta:this.theta},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);iF.className="ThresholdedReLU",ax(iF);var oF=function(e){function t(t){var n;return(n=e.call(this,null==t?{}:t)||this).DEFAULT_AXIS=1,null==t&&(t={}),n.softmax=(new UD).apply,n.axis=null==t.axis?n.DEFAULT_AXIS:t.axis,n}qm(t,e);var n=t.prototype;return n.call=function(e,t){var n=LR(e);return this.softmax(n,this.axis)},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t={axis:this.axis},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);function sF(e,t,n){if("number"==typeof e)return ZC(e,t);if(e.length!==t)throw new XC("The "+n+" argument must be an integer or tuple of "+t+" integers. Received: "+e.length+" elements.");for(var r=0;r<t;++r){var a=e[r];if((i=a)!==parseInt(i.toString(),10))throw new XC("The "+n+" argument must be an integer or tuple of "+t+" integers. Received: "+JSON.stringify(e)+" including a non-integer number "+a)}return e;var i}function uF(e,t,n,r,a){return void 0===a&&(a=1),null==e?e:(i="same"===n?e:e-(t+(t-1)*(a-1))+1,Math.floor((i+r-1)/r));var i}function lF(e,t,n,r){if(null==e)return null;if("valid"===r)e=e*t+GE([n-t,0]);else{if("same"!==r)throw new XC("Unsupport padding mode: "+r+".");e*=t}return e}function cF(e,t){return dx((function(){return DE(t),"channelsFirst"===t?Tb(e,[0,2,3,1]):e}))}function pF(e,t){return dx((function(){return DE(t),"channelsFirst"===t?Tb(e,[0,2,3,4,1]):e}))}function hF(e,t,n,r,a,i,o){return void 0===r&&(r=1),void 0===a&&(a="valid"),void 0===o&&(o=1),dx((function(){if(null==i&&(i="channelsLast"),DE(i),3!==e.shape.length)throw new XC("The input of a conv1dWithBias operation should be 3, but is "+e.shape.length+" instead.");if(3!==t.shape.length)throw new XC("The kernel for a conv1dWithBias operation should be 3, but is "+t.shape.length+" instead");if(null!=n&&1!==n.shape.length)throw new XC("The bias for a conv1dWithBias operation should be 1, but is "+t.shape.length+" instead");if("channelsFirst"===i&&(e=Tb(e,[0,2,1])),"causal"===a)throw new YC("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");var s=yw(e,t,r,"same"===a?"same":"valid","NWC",o);return null!=n&&(s=aR(s,n)),s}))}function fF(e,t,n,r,a,i,o,s){return void 0===r&&(r=[1,1]),void 0===a&&(a="valid"),void 0===s&&(s=null),dx((function(){if(null==i&&(i="channelsLast"),DE(i),3!==e.rank&&4!==e.rank)throw new XC("conv2dWithBiasActivation expects input to be of rank 3 or 4, but received "+e.rank+".");if(3!==t.rank&&4!==t.rank)throw new XC("conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received "+e.rank+".");var u=cF(e,i);if("causal"===a)throw new YC("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return u=KI({x:u,filter:t,strides:r,pad:"same"===a?"same":"valid",dilations:o,dataFormat:"NHWC",bias:n,activation:s}),"channelsFirst"===i&&(u=Tb(u,[0,3,1,2])),u}))}function dF(e,t,n,r,a,i,o){return void 0===r&&(r=[1,1,1]),void 0===a&&(a="valid"),dx((function(){if(null==i&&(i="channelsLast"),DE(i),4!==e.rank&&5!==e.rank)throw new XC("conv3dWithBias expects input to be of rank 4 or 5, but received "+e.rank+".");if(4!==t.rank&&5!==t.rank)throw new XC("conv3dWithBias expects kernel to be of rank 4 or 5, but received "+e.rank+".");var s=pF(e,i);if("causal"===a)throw new YC("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return s=ww(s,t,r,"same"===a?"same":"valid","NDHWC",o),null!=n&&(s=aR(s,n)),"channelsFirst"===i&&(s=Tb(s,[0,4,1,2,3])),s}))}oF.className="Softmax",ax(oF);var mF=function(e){function t(n,r){var a;if((a=e.call(this,r)||this).bias=null,a.DEFAULT_KERNEL_INITIALIZER="glorotNormal",a.DEFAULT_BIAS_INITIALIZER="zeros",t.verifyArgs(r),a.rank=n,hE(a.rank,"rank"),1!==a.rank&&2!==a.rank&&3!==a.rank)throw new YC("Convolution layer for rank other than 1, 2, or 3 ("+a.rank+") is not implemented yet.");if(a.kernelSize=sF(r.kernelSize,n,"kernelSize"),a.strides=sF(null==r.strides?1:r.strides,n,"strides"),a.padding=null==r.padding?"valid":r.padding,FE(a.padding),a.dataFormat=null==r.dataFormat?"channelsLast":r.dataFormat,DE(a.dataFormat),a.activation=KD(r.activation),a.useBias=null==r.useBias||r.useBias,a.biasInitializer=ER(r.biasInitializer||a.DEFAULT_BIAS_INITIALIZER),a.biasConstraint=NE(r.biasConstraint),a.biasRegularizer=eF(r.biasRegularizer),a.activityRegularizer=eF(r.activityRegularizer),a.dilationRate=sF(null==r.dilationRate?1:r.dilationRate,n,"dilationRate"),1===a.rank&&Array.isArray(a.dilationRate)&&1!==a.dilationRate.length)throw new XC("dilationRate must be a number or an array of a single number for 1D convolution, but received "+JSON.stringify(a.dilationRate));if(2===a.rank){if("number"==typeof a.dilationRate)a.dilationRate=[a.dilationRate,a.dilationRate];else if(2!==a.dilationRate.length)throw new XC("dilationRate must be a number or array of two numbers for 2D convolution, but received "+JSON.stringify(a.dilationRate))}else if(3===a.rank)if("number"==typeof a.dilationRate)a.dilationRate=[a.dilationRate,a.dilationRate,a.dilationRate];else if(3!==a.dilationRate.length)throw new XC("dilationRate must be a number or array of three numbers for 3D convolution, but received "+JSON.stringify(a.dilationRate));return a}return qm(t,e),t.verifyArgs=function(e){if(QC("kernelSize"in e,"required key 'kernelSize' not in config"),"number"!=typeof e.kernelSize&&!pE(e.kernelSize,"number",1,3))throw new XC("BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received "+JSON.stringify(e.kernelSize)+".")},t.prototype.getConfig=function(){var t={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:HD(this.activation),useBias:this.useBias,biasInitializer:CR(this.biasInitializer),biasRegularizer:QD(this.biasRegularizer),activityRegularizer:QD(this.activityRegularizer),biasConstraint:wE(this.biasConstraint)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR),vF=function(e){function t(n,r){var a;return(a=e.call(this,n,r)||this).kernel=null,t.verifyArgs(r),a.filters=r.filters,hE(a.filters,"filters"),a.kernelInitializer=ER(r.kernelInitializer||a.DEFAULT_KERNEL_INITIALIZER),a.kernelConstraint=NE(r.kernelConstraint),a.kernelRegularizer=eF(r.kernelRegularizer),a}qm(t,e);var n=t.prototype;return n.build=function(e){var t;e=zR(e);var n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new XC("The channel dimension of the input should be defined. Found "+e[n]);var r=e[n],a=this.kernelSize.concat([r,this.filters]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[{ndim:this.rank+2,axes:(t={},t[n]=r,t)}],this.built=!0},n.call=function(e,t){var n=this;return dx((function(){var t;e=LR(e);var r=null==n.bias?null:n.bias.read(),a=fE(n.activation.getClassName());if(null!=a&&2===n.rank)t=fF(e,n.kernel.read(),r,n.strides,n.padding,n.dataFormat,n.dilationRate,a);else{if(1===n.rank)t=hF(e,n.kernel.read(),r,n.strides[0],n.padding,n.dataFormat,n.dilationRate[0]);else if(2===n.rank)t=fF(e,n.kernel.read(),r,n.strides,n.padding,n.dataFormat,n.dilationRate);else{if(3!==n.rank)throw new YC("convolutions greater than 3D are not implemented yet.");t=dF(e,n.kernel.read(),r,n.strides,n.padding,n.dataFormat,n.dilationRate)}null!=n.activation&&(t=n.activation.apply(t))}return t}))},n.computeOutputShape=function(e){e=zR(e);for(var t=[],n="channelsLast"===this.dataFormat?e.slice(1,e.length-1):e.slice(2),r=0;r<n.length;++r){var a=uF(n[r],this.kernelSize[r],this.padding,this.strides[r],"number"==typeof this.dilationRate?this.dilationRate:this.dilationRate[r]);t.push(a)}var i=[e[0]];return"channelsLast"===this.dataFormat?(i=i.concat(t)).push(this.filters):(i.push(this.filters),i=i.concat(t)),i},n.getConfig=function(){var t={filters:this.filters,kernelInitializer:CR(this.kernelInitializer),kernelRegularizer:QD(this.kernelRegularizer),kernelConstraint:wE(this.kernelConstraint)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t.verifyArgs=function(e){if(!("filters"in e)||"number"!=typeof e.filters||e.filters<1)throw new XC("Convolution layer expected config.filters to be a 'number' > 0 but got "+JSON.stringify(e.filters))},t}(mF),gF=function(e){function t(n){var r;return r=e.call(this,2,n)||this,t.verifyArgs(n),r}return qm(t,e),t.prototype.getConfig=function(){var t=e.prototype.getConfig.call(this);return delete t.rank,t},t.verifyArgs=function(e){if("number"!=typeof e.kernelSize&&!pE(e.kernelSize,"number",1,2))throw new XC("Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received "+JSON.stringify(e.kernelSize)+".")},t}(vF);gF.className="Conv2D",ax(gF);var yF=function(e){function t(n){var r;return r=e.call(this,3,n)||this,t.verifyArgs(n),r}return qm(t,e),t.prototype.getConfig=function(){var t=e.prototype.getConfig.call(this);return delete t.rank,t},t.verifyArgs=function(e){if("number"!=typeof e.kernelSize&&(!Array.isArray(e.kernelSize)||1!==e.kernelSize.length&&3!==e.kernelSize.length))throw new XC("Conv3D expects config.kernelSize to be number or [number, number, number], but received "+JSON.stringify(e.kernelSize)+".")},t}(vF);yF.className="Conv3D",ax(yF);var bF=function(e){function t(t){var n;if((n=e.call(this,t)||this).inputSpec=[new UR({ndim:4})],"same"!==n.padding&&"valid"!==n.padding)throw new XC("Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode "+n.padding);return n}qm(t,e);var n=t.prototype;return n.build=function(e){var t;if(4!==(e=zR(e)).length)throw new XC("Input should have rank 4; Received input shape: "+JSON.stringify(e));var n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new XC("The channel dimension of the inputs should be defined. Found `None`.");var r=e[n],a=this.kernelSize.concat([this.filters,r]);this.kernel=this.addWeight("kernel",a,"float32",this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint)),this.inputSpec=[new UR({ndim:4,axes:(t={},t[n]=r,t)})],this.built=!0},n.call=function(e,t){var n=this;return dx((function(){var t=LR(e);if(4!==t.shape.length)throw new XC("Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-"+t.shape.length);var r,a,i=t.shape,o=i[0];"channelsFirst"===n.dataFormat?(r=2,a=3):(r=1,a=2);var s=i[r],u=i[a],l=n.kernelSize[0],c=n.kernelSize[1],p=n.strides[0],h=n.strides[1],f=[o,lF(s,p,l,n.padding),lF(u,h,c,n.padding),n.filters];"channelsLast"!==n.dataFormat&&(t=Tb(t,[0,2,3,1]));var d=xw(t,n.kernel.read(),f,n.strides,n.padding);return"channelsLast"!==n.dataFormat&&(d=Tb(d,[0,3,1,2])),null!=n.bias&&(d=aR(d,n.bias.read(),n.dataFormat)),null!=n.activation&&(d=n.activation.apply(d)),d}))},n.computeOutputShape=function(e){var t,n,r,a=(e=zR(e)).slice();"channelsFirst"===this.dataFormat?(t=1,n=2,r=3):(t=3,n=1,r=2);var i=this.kernelSize[0],o=this.kernelSize[1],s=this.strides[0],u=this.strides[1];return a[t]=this.filters,a[n]=lF(a[n],s,i,this.padding),a[r]=lF(a[r],u,o,this.padding),a},n.getConfig=function(){var t=e.prototype.getConfig.call(this);return delete t.dilationRate,t},t}(gF);bF.className="Conv2DTranspose",ax(bF);var xF=function(e){function t(t,n){var r;if((r=e.call(this,t,n)||this).DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",r.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",r.depthwiseKernel=null,r.pointwiseKernel=null,null==n.filters)throw new XC("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=n.kernelInitializer||null!=n.kernelRegularizer||null!=n.kernelConstraint)throw new XC("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=n.padding&&"same"!==n.padding&&"valid"!==n.padding)throw new XC("SeparableConv"+r.rank+"D supports only padding modes: 'same' and 'valid', but received "+JSON.stringify(n.padding));return r.depthMultiplier=null==n.depthMultiplier?1:n.depthMultiplier,r.depthwiseInitializer=ER(n.depthwiseInitializer||r.DEFAULT_DEPTHWISE_INITIALIZER),r.depthwiseRegularizer=eF(n.depthwiseRegularizer),r.depthwiseConstraint=NE(n.depthwiseConstraint),r.pointwiseInitializer=ER(n.depthwiseInitializer||r.DEFAULT_POINTWISE_INITIALIZER),r.pointwiseRegularizer=eF(n.pointwiseRegularizer),r.pointwiseConstraint=NE(n.pointwiseConstraint),r}qm(t,e);var n=t.prototype;return n.build=function(e){var t;if((e=zR(e)).length<this.rank+2)throw new XC("Inputs to SeparableConv"+this.rank+"D should have rank "+(this.rank+2)+", but received input shape: "+JSON.stringify(e));var n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n]||e[n]<0)throw new XC("The channel dimension of the inputs should be defined, but found "+JSON.stringify(e[n]));for(var r=e[n],a=this.kernelSize.concat([r,this.depthMultiplier]),i=[],o=0;o<this.rank;++o)i.push(1);i.push(r*this.depthMultiplier,this.filters);this.depthwiseKernel=this.addWeight("depthwise_kernel",a,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",i,"float32",this.pointwiseInitializer,this.pointwiseRegularizer,!0,this.pointwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[this.filters],"float32",this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.inputSpec=[new UR({ndim:this.rank+2,axes:(t={},t[n]=r,t)})],this.built=!0},n.call=function(e,t){var n=this;return dx((function(){var t;if(e=LR(e),1===n.rank)throw new YC("1D separable convolution is not implemented yet.");return 2===n.rank&&("channelsFirst"===n.dataFormat&&(e=Tb(e,[0,2,3,1])),t=MN(e,n.depthwiseKernel.read(),n.pointwiseKernel.read(),n.strides,n.padding,n.dilationRate,"NHWC")),n.useBias&&(t=aR(t,n.bias.read(),n.dataFormat)),null!=n.activation&&(t=n.activation.apply(t)),"channelsFirst"===n.dataFormat&&(t=Tb(t,[0,3,1,2])),t}))},n.getConfig=function(){var t=e.prototype.getConfig.call(this);return delete t.rank,delete t.kernelInitializer,delete t.kernelRegularizer,delete t.kernelConstraint,t.depthwiseInitializer=CR(this.depthwiseInitializer),t.pointwiseInitializer=CR(this.pointwiseInitializer),t.depthwiseRegularizer=QD(this.depthwiseRegularizer),t.pointwiseRegularizer=QD(this.pointwiseRegularizer),t.depthwiseConstraint=wE(this.depthwiseConstraint),t.pointwiseConstraint=wE(this.pointwiseConstraint),t},t}(vF);xF.className="SeparableConv";var wF=function(e){function t(t){return e.call(this,2,t)||this}return qm(t,e),t}(xF);wF.className="SeparableConv2D",ax(wF);var kF=function(e){function t(n){var r;return r=e.call(this,1,n)||this,t.verifyArgs(n),r.inputSpec=[{ndim:3}],r}return qm(t,e),t.prototype.getConfig=function(){var t=e.prototype.getConfig.call(this);return delete t.rank,delete t.dataFormat,t},t.verifyArgs=function(e){if("number"!=typeof e.kernelSize&&!pE(e.kernelSize,"number",1,1))throw new XC("Conv1D expects config.kernelSize to be number or number[] with length 1, but received "+JSON.stringify(e.kernelSize)+".")},t}(vF);kF.className="Conv1D",ax(kF);var NF=function(e){function t(t){var n;return n=e.call(this,t)||this,"number"==typeof t.cropping?n.cropping=[[t.cropping,t.cropping],[t.cropping,t.cropping]]:"number"==typeof t.cropping[0]?n.cropping=[[t.cropping[0],t.cropping[0]],[t.cropping[1],t.cropping[1]]]:n.cropping=t.cropping,n.dataFormat=void 0===t.dataFormat?"channelsLast":t.dataFormat,n.inputSpec=[{ndim:4}],n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return"channelsFirst"===this.dataFormat?[e[0],e[1],e[2]-this.cropping[0][0]-this.cropping[0][1],e[3]-this.cropping[1][0]-this.cropping[1][1]]:[e[0],e[1]-this.cropping[0][0]-this.cropping[0][1],e[2]-this.cropping[1][0]-this.cropping[1][1],e[3]]},n.call=function(e,t){var n=this;return dx((function(){if(e=LR(e),"channelsLast"===n.dataFormat){var t=YE(e,n.cropping[0][0],e.shape[1]-n.cropping[0][0]-n.cropping[0][1],2);return YE(t,n.cropping[1][0],e.shape[2]-n.cropping[1][1]-n.cropping[1][0],3)}var r=YE(e,n.cropping[0][0],e.shape[2]-n.cropping[0][0]-n.cropping[0][1],3);return YE(r,n.cropping[1][0],e.shape[3]-n.cropping[1][1]-n.cropping[1][0],4)}))},n.getConfig=function(){var t={cropping:this.cropping,dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);NF.className="Cropping2D",ax(NF);var IF=function(e){function t(t){var n,r;return(n=e.call(this,t)||this).DEFAULT_SIZE=[2,2],n.inputSpec=[{ndim:4}],n.size=null==t.size?n.DEFAULT_SIZE:t.size,n.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,DE(n.dataFormat),n.interpolation=null==t.interpolation?"nearest":t.interpolation,r=n.interpolation,cE(TE,"InterpolationFormat",r),n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){if("channelsFirst"===this.dataFormat){var t=null==e[2]?null:this.size[0]*e[2],n=null==e[3]?null:this.size[1]*e[3];return[e[0],e[1],t,n]}var r=null==e[1]?null:this.size[0]*e[1],a=null==e[2]?null:this.size[1]*e[2];return[e[0],r,a,e[3]]},n.call=function(e,t){var n=this;return dx((function(){var t=LR(e),r=t.shape;if("channelsFirst"===n.dataFormat){t=Tb(t,[0,2,3,1]);var a=n.size[0]*r[2],i=n.size[1]*r[3],o="nearest"===n.interpolation?t.resizeNearestNeighbor([a,i]):t.resizeBilinear([a,i]);return Tb(o,[0,3,1,2])}var s=n.size[0]*r[1],u=n.size[1]*r[2];return"nearest"===n.interpolation?t.resizeNearestNeighbor([s,u]):t.resizeBilinear([s,u])}))},n.getConfig=function(){var t={size:this.size,dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);IF.className="UpSampling2D",ax(IF);var SF=function(e){function t(t){var n;return(n=e.call(this,2,t)||this).depthwiseKernel=null,n.depthMultiplier=null==t.depthMultiplier?1:t.depthMultiplier,n.depthwiseInitializer=ER(t.depthwiseInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.depthwiseConstraint=NE(t.depthwiseConstraint),n.depthwiseRegularizer=eF(t.depthwiseRegularizer),n}qm(t,e);var n=t.prototype;return n.build=function(e){if((e=zR(e)).length<4)throw new XC("Inputs to DepthwiseConv2D should have rank 4. Received input shape: "+JSON.stringify(e)+".");var t="channelsFirst"===this.dataFormat?1:3;if(null==e[t]||e[t]<0)throw new XC("The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not ("+e[t]+").");var n=e[t],r=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},n.call=function(e,t){var n=this;return dx((function(){e=LR(e);var t,r,a,i,o,s,u=(t=e,r=n.depthwiseKernel.read(),a=n.strides,i=n.padding,o=n.dataFormat,s=null,void 0===a&&(a=[1,1]),void 0===i&&(i="valid"),dx((function(){null==o&&(o="channelsLast"),DE(o);var e=cF(t,o);if(4!==t.rank)throw new XC("Input for depthwiseConv2d is required to be 4-D, but is instead "+t.rank+"-D");if(4!==r.rank)throw new XC("depthwiseKernel is required to be 4-D, but is instead "+r.rank+"-D");return e=Rw(e,r,a,"same"===i?"same":"valid","NHWC",s),"channelsFirst"===o&&(e=Tb(e,[0,3,1,2])),e})));return n.useBias&&(u=aR(u,n.bias.read(),n.dataFormat)),null!=n.activation&&(u=n.activation.apply(u)),u}))},n.computeOutputShape=function(e){e=zR(e);var t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[1]*this.depthMultiplier:e[3]*this.depthMultiplier,a=uF(t,this.kernelSize[0],this.padding,this.strides[0]),i=uF(n,this.kernelSize[1],this.padding,this.strides[1]);return"channelsFirst"===this.dataFormat?[e[0],r,a,i]:[e[0],a,i,r]},n.getConfig=function(){var t=e.prototype.getConfig.call(this);return t.depthMultiplier=this.depthMultiplier,t.depthwiseInitializer=CR(this.depthwiseInitializer),t.depthwiseRegularizer=QD(this.depthwiseRegularizer),t.depthwiseConstraint=wE(this.depthwiseRegularizer),t},t}(mF);function TF(e,t,n,r){if(Array.isArray(e)){if(null!=t||null!=n)throw new XC("When inputs is an array, neither initialState or constants should be provided");null!=r&&(n=e.slice(e.length-r,e.length),e=e.slice(0,e.length-r)),e.length>1&&(t=e.slice(1,e.length)),e=e[0]}function a(e){return null==e||Array.isArray(e)?e:[e]}return{inputs:e,initialState:t=a(t),constants:n=a(n)}}function CF(e,t,n,r,a,i,o,s){return void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===s&&(s=!1),dx((function(){var u=t.shape.length;if(u<3)throw new XC("Input should be at least 3D, but is "+u+"D.");var l=[1,0].concat(jE(2,u));if(t=Tb(t,l),null!=i)throw new YC("The rnn() functoin of the deeplearn.js backend does not support constants yet.");o&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=a&&((a=a.asType("bool").asType("float32")).rank===u-1&&(a=Gw(a,-1)),a=Tb(a,l)),r&&(t=TN(t,0),null!=a&&(a=TN(a,0)));var c,p,h=[],f=n,d=t.shape[0],m=cI(t);null!=a&&(p=cI(a));for(var v,g=function(t){var n=m[t],r=dx((function(){return e(n,f)}));if(null==a)c=r[0],f=r[1];else{var i=dx((function(){var e=p[t],n=Xk(e).sub(e);return{output:r[0].mul(e).add(f[0].mul(n)),newStates:f.map((function(t,a){return r[1][a].mul(e).add(t.mul(n))}))}}));c=i.output,f=i.newStates}s&&h.push(c)},y=0;y<d;++y)g(y);if(s){v=eI(h,1)}return[c,v,f]}))}SF.className="DepthwiseConv2D",ax(SF);var EF=function(e){function t(t){var n,r;if(n=e.call(this,t)||this,null==t.cell)throw new XC("cell property is missing for the constructor of RNN.");if(null==(r=Array.isArray(t.cell)?new LF({cells:t.cell}):t.cell).stateSize)throw new XC("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");return n.cell=r,n.returnSequences=null!=t.returnSequences&&t.returnSequences,n.returnState=null!=t.returnState&&t.returnState,n.goBackwards=null!=t.goBackwards&&t.goBackwards,n._stateful=null!=t.stateful&&t.stateful,n.unroll=null!=t.unroll&&t.unroll,n.supportsMasking=!0,n.inputSpec=[new UR({ndim:3})],n.stateSpec=null,n.states_=null,n.numConstants=null,n.keptStates=[],n}qm(t,e);var n=t.prototype;return n.getStates=function(){return null==this.states_?jE(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map((function(e){return null})):this.states_},n.setStates=function(e){this.states_=e},n.computeOutputShape=function(e){OR(e)&&(e=e[0]),e=e;var t=this.cell.stateSize;Array.isArray(t)||(t=[t]);var n,r=t[0];if(n=this.returnSequences?[e[0],e[1],r]:[e[0],r],this.returnState){for(var a,i=[],o=tv(t);!(a=o()).done;){var s=a.value;i.push([e[0],s])}return[n].concat(i)}return n},n.computeMask=function(e,t){var n=this;return dx((function(){Array.isArray(t)&&(t=t[0]);var e=n.returnSequences?t:null;if(n.returnState){var r=n.states.map((function(e){return null}));return[e].concat(r)}return e}))},n.build=function(e){if(null!=this.numConstants)throw new YC("Constants support is not implemented in RNN yet.");OR(e)&&(e=e[0]),e=e;var t=this.stateful?e[0]:null,n=e.slice(2);this.inputSpec[0]=new UR({shape:[t,null].concat(n)});var r,a=[e[0]].concat(e.slice(2));if(this.cell.build(a),r=Array.isArray(this.cell.stateSize)?this.cell.stateSize:[this.cell.stateSize],null!=this.stateSpec){if(!dv(this.stateSpec.map((function(e){return e.shape[e.shape.length-1]})),r))throw new XC("An initialState was passed that is not compatible with cell.stateSize. Received stateSpec="+this.stateSpec+"; However cell.stateSize is "+this.cell.stateSize)}else this.stateSpec=r.map((function(e){return new UR({shape:[null,e]})}));this.stateful&&this.resetStates()},n.resetStates=function(e,t){var n=this;void 0===t&&(t=!1),dx((function(){if(!n.stateful)throw new qC("Cannot call resetStates() on an RNN Layer that is not stateful.");var r=n.inputSpec[0].shape[0];if(null==r)throw new XC("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==n.states_)Array.isArray(n.cell.stateSize)?n.states_=n.cell.stateSize.map((function(e){return qk([r,e])})):n.states_=[qk([r,n.cell.stateSize])];else if(null==e)mx(n.states_),null!=n.keptStates&&(mx(n.keptStates),n.keptStates=[]),Array.isArray(n.cell.stateSize)?n.states_=n.cell.stateSize.map((function(e){return qk([r,e])})):n.states_[0]=qk([r,n.cell.stateSize]);else{if(Array.isArray(e)||(e=[e]),e.length!==n.states_.length)throw new XC("Layer "+n.name+" expects "+n.states_.length+" state(s), but it received "+e.length+" state value(s). Input received: "+e);!0===t?n.keptStates.push(n.states_.slice()):mx(n.states_);for(var a=0;a<n.states_.length;++a){var i=e[a],o=Array.isArray(n.cell.stateSize)?n.cell.stateSize[a]:n.cell.stateSize,s=[r,o];if(!dv(i.shape,s))throw new XC("State "+a+" is incompatible with layer "+n.name+": expected shape="+s+", received shape="+i.shape);n.states_[a]=i}}n.states_=n.states_.map((function(e){return vx(e.clone())}))}))},n.apply=function(t,n){var r=null==n?null:n.initialState,a=null==n?null:n.constants;null==n&&(n={});var i=TF(t,r,a,this.numConstants);t=i.inputs,r=i.initialState,a=i.constants;var o=[],s=[];if(null!=r){n.initialState=r,o=o.concat(r),this.stateSpec=[];for(var u,l=tv(r);!(u=l()).done;){var c=u.value;this.stateSpec.push(new UR({shape:c.shape}))}s=s.concat(this.stateSpec)}if(null!=a&&(n.constants=a,o=o.concat(a),this.numConstants=a.length),o[0]instanceof GR){var p=[t].concat(o),h=this.inputSpec.concat(s),f=this.inputSpec;this.inputSpec=h;var d=e.prototype.apply.call(this,p,n);return this.inputSpec=f,d}return e.prototype.apply.call(this,t,n)},n.call=function(e,t){var n=this;return dx((function(){var r=null==t?null:t.mask,a=null==t?null:t.training,i=null==t?null:t.initialState;e=LR(e),null==i&&(i=n.stateful?n.states_:n.getInitialState(e));var o=Array.isArray(n.cell.stateSize)?n.cell.stateSize.length:1;if(i.length!==o)throw new XC("RNN Layer has "+o+" state(s) but was passed "+i.length+" initial state(s).");n.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");var s={training:a},u=CF((function(e,t){var r=n.cell.call([e].concat(t),s);return[r[0],r.slice(1)]}),e,i,n.goBackwards,r,null,n.unroll,n.returnSequences),l=u[0],c=u[1],p=u[2];n.stateful&&n.resetStates(p,a);var h=n.returnSequences?c:l;return n.returnState?[h].concat(p):h}))},n.getInitialState=function(e){var t=this;return dx((function(){var n=qk(e.shape);return n=qE(n=gk(n,[1,2])),Array.isArray(t.cell.stateSize)?t.cell.stateSize.map((function(e){return e>1?QE(n,[1,e]):n})):t.cell.stateSize>1?[QE(n,[1,t.cell.stateSize])]:[n]}))},n.setFastWeightInitDuringBuild=function(t){e.prototype.setFastWeightInitDuringBuild.call(this,t),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(t)},n.getConfig=function(){var n=e.prototype.getConfig.call(this),r={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(r.numConstants=this.numConstants);var a=this.cell.getConfig();return this.getClassName()===t.className&&(r.cell={className:this.cell.getClassName(),config:a}),Object.assign({},a,n,r)},t.fromConfig=function(e,t,n){void 0===n&&(n={});var r=uA(t.cell,n);return new e(Object.assign(t,{cell:r}))},Hm(t,[{key:"states",get:function(){if(null==this.states_){for(var e=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,t=[],n=0;n<e;++n)t.push(null);return t}return this.states_},set:function(e){this.states_=e}},{key:"trainableWeights",get:function(){return this.trainable?this.cell.trainableWeights:[]}},{key:"nonTrainableWeights",get:function(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights}}]),t}(KR);EF.className="RNN",ax(EF);var RF=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t}(KR),AF=function(e){function t(t){var n;return(n=e.call(this,t)||this).DEFAULT_ACTIVATION="tanh",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",n.units=t.units,hE(n.units,"units"),n.activation=KD(null==t.activation?n.DEFAULT_ACTIVATION:t.activation),n.useBias=null==t.useBias||t.useBias,n.kernelInitializer=ER(t.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=ER(t.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=ER(t.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelRegularizer=eF(t.kernelRegularizer),n.recurrentRegularizer=eF(t.recurrentRegularizer),n.biasRegularizer=eF(t.biasRegularizer),n.kernelConstraint=NE(t.kernelConstraint),n.recurrentConstraint=NE(t.recurrentConstraint),n.biasConstraint=NE(t.biasConstraint),n.dropout=UE([1,GE([0,null==t.dropout?0:t.dropout])]),n.recurrentDropout=UE([1,GE([0,null==t.recurrentDropout?0:t.recurrentDropout])]),n.stateSize=n.units,n.dropoutMask=null,n.recurrentDropoutMask=null,n}qm(t,e);var n=t.prototype;return n.build=function(e){e=zR(e),this.kernel=this.addWeight("kernel",[e[e.length-1],this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},n.call=function(e,t){var n=this;return dx((function(){if(2!==(e=e).length)throw new XC("SimpleRNNCell expects 2 input Tensors, got "+e.length+".");var r=e[1];e=e[0];var a,i=null!=t.training&&t.training;0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=zF({ones:function(){return Xk(e)},rate:n.dropout,training:i})),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=zF({ones:function(){return Xk(r)},rate:n.recurrentDropout,training:i}));var o=n.dropoutMask,s=n.recurrentDropoutMask;a=eR(null!=o?Nx(e,o):e,n.kernel.read()),null!=n.bias&&(a=aR(a,n.bias.read())),null!=s&&(r=Nx(r,s));var u=xx(a,eR(r,n.recurrentKernel.read()));return null!=n.activation&&(u=n.activation.apply(u)),[u,u]}))},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={units:this.units,activation:HD(this.activation),useBias:this.useBias,kernelInitializer:CR(this.kernelInitializer),recurrentInitializer:CR(this.recurrentInitializer),biasInitializer:CR(this.biasInitializer),kernelRegularizer:QD(this.kernelRegularizer),recurrentRegularizer:QD(this.recurrentRegularizer),biasRegularizer:QD(this.biasRegularizer),activityRegularizer:QD(this.activityRegularizer),kernelConstraint:wE(this.kernelConstraint),recurrentConstraint:wE(this.recurrentConstraint),biasConstraint:wE(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout};return Object.assign({},t,n)},t}(RF);AF.className="SimpleRNNCell",ax(AF);var DF=function(e){function t(t){return t.cell=new AF(t),e.call(this,t)||this}return qm(t,e),t.prototype.call=function(t,n){var r=this;return dx((function(){null!=r.cell.dropoutMask&&(mx(r.cell.dropoutMask),r.cell.dropoutMask=null),null!=r.cell.recurrentDropoutMask&&(mx(r.cell.recurrentDropoutMask),r.cell.recurrentDropoutMask=null);var a=null==n?null:n.mask,i=null==n?null:n.training,o=null==n?null:n.initialState;return e.prototype.call.call(r,t,{mask:a,training:i,initialState:o})}))},t.fromConfig=function(e,t){return new e(t)},t}(EF);DF.className="SimpleRNN",ax(DF);var FF=function(e){function t(t){var n;if((n=e.call(this,t)||this).DEFAULT_ACTIVATION="tanh",n.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",t.resetAfter)throw new XC("GRUCell does not support reset_after parameter set to true.");return n.units=t.units,hE(n.units,"units"),n.activation=KD(void 0===t.activation?n.DEFAULT_ACTIVATION:t.activation),n.recurrentActivation=KD(void 0===t.recurrentActivation?n.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),n.useBias=null==t.useBias||t.useBias,n.kernelInitializer=ER(t.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=ER(t.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=ER(t.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelRegularizer=eF(t.kernelRegularizer),n.recurrentRegularizer=eF(t.recurrentRegularizer),n.biasRegularizer=eF(t.biasRegularizer),n.kernelConstraint=NE(t.kernelConstraint),n.recurrentConstraint=NE(t.recurrentConstraint),n.biasConstraint=NE(t.biasConstraint),n.dropout=UE([1,GE([0,null==t.dropout?0:t.dropout])]),n.recurrentDropout=UE([1,GE([0,null==t.recurrentDropout?0:t.recurrentDropout])]),n.implementation=t.implementation,n.stateSize=n.units,n.dropoutMask=null,n.recurrentDropoutMask=null,n}qm(t,e);var n=t.prototype;return n.build=function(e){var t=(e=zR(e))[e.length-1];this.kernel=this.addWeight("kernel",[t,3*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,3*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias?this.bias=this.addWeight("bias",[3*this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0},n.call=function(e,t){var n=this;return dx((function(){if(2!==(e=e).length)throw new XC("GRUCell expects 2 input Tensors (inputs, h, c), got "+e.length+".");var r=null!=t.training&&t.training,a=e[1];e=e[0],0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=zF({ones:function(){return Xk(e)},rate:n.dropout,training:r,count:3})),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=zF({ones:function(){return Xk(a)},rate:n.recurrentDropout,training:r,count:3}));var i,o,s,u=n.dropoutMask,l=n.recurrentDropoutMask;0<n.dropout&&n.dropout<1&&(e=Nx(e,u[0]));var c=eR(e,n.kernel.read());n.useBias&&(c=aR(c,n.bias.read())),0<n.recurrentDropout&&n.recurrentDropout<1&&(a=Nx(a,l[0]));var p=n.recurrentKernel.read(),h=YN(p,[2*n.units,n.units],p.rank-1),f=h[0],d=h[1],m=eR(a,f),v=YN(c,3,c.rank-1),g=v[0],y=v[1],b=v[2],x=YN(m,2,m.rank-1),w=x[0],k=x[1];i=n.recurrentActivation.apply(xx(g,w)),o=n.recurrentActivation.apply(xx(y,k));var N=eR(Nx(o,a),d);s=n.activation.apply(xx(b,N));var I=xx(Nx(i,a),Nx(xx(1,hk(i)),s));return[I,I]}))},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={units:this.units,activation:HD(this.activation),recurrentActivation:HD(this.recurrentActivation),useBias:this.useBias,kernelInitializer:CR(this.kernelInitializer),recurrentInitializer:CR(this.recurrentInitializer),biasInitializer:CR(this.biasInitializer),kernelRegularizer:QD(this.kernelRegularizer),recurrentRegularizer:QD(this.recurrentRegularizer),biasRegularizer:QD(this.biasRegularizer),activityRegularizer:QD(this.activityRegularizer),kernelConstraint:wE(this.kernelConstraint),recurrentConstraint:wE(this.recurrentConstraint),biasConstraint:wE(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation,resetAfter:!1};return Object.assign({},t,n)},t}(RF);FF.className="GRUCell",ax(FF);var _F=function(e){function t(t){return 0===t.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),t.cell=new FF(t),e.call(this,t)||this}return qm(t,e),t.prototype.call=function(t,n){var r=this;return dx((function(){null!=r.cell.dropoutMask&&(mx(r.cell.dropoutMask),r.cell.dropoutMask=null),null!=r.cell.recurrentDropoutMask&&(mx(r.cell.recurrentDropoutMask),r.cell.recurrentDropoutMask=null);var a=null==n?null:n.mask,i=null==n?null:n.training,o=null==n?null:n.initialState;return e.prototype.call.call(r,t,{mask:a,training:i,initialState:o})}))},t.fromConfig=function(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)},t}(EF);_F.className="GRU",ax(_F);var OF=function(e){function t(t){var n;return(n=e.call(this,t)||this).DEFAULT_ACTIVATION="tanh",n.DEFAULT_RECURRENT_ACTIVATION="hardSigmoid",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",n.units=t.units,hE(n.units,"units"),n.activation=KD(void 0===t.activation?n.DEFAULT_ACTIVATION:t.activation),n.recurrentActivation=KD(void 0===t.recurrentActivation?n.DEFAULT_RECURRENT_ACTIVATION:t.recurrentActivation),n.useBias=null==t.useBias||t.useBias,n.kernelInitializer=ER(t.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=ER(t.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=ER(t.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.unitForgetBias=t.unitForgetBias,n.kernelRegularizer=eF(t.kernelRegularizer),n.recurrentRegularizer=eF(t.recurrentRegularizer),n.biasRegularizer=eF(t.biasRegularizer),n.kernelConstraint=NE(t.kernelConstraint),n.recurrentConstraint=NE(t.recurrentConstraint),n.biasConstraint=NE(t.biasConstraint),n.dropout=UE([1,GE([0,null==t.dropout?0:t.dropout])]),n.recurrentDropout=UE([1,GE([0,null==t.recurrentDropout?0:t.recurrentDropout])]),n.implementation=t.implementation,n.stateSize=[n.units,n.units],n.dropoutMask=null,n.recurrentDropoutMask=null,n}qm(t,e);var n=t.prototype;return n.build=function(e){var t,n,r=(e=zR(e))[e.length-1];if(this.kernel=this.addWeight("kernel",[r,4*this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.recurrentKernel=this.addWeight("recurrent_kernel",[this.units,4*this.units],null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){if(this.unitForgetBias){var a=this.biasInitializer,i=this.units;n=new((t=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e,t){var n=a.apply([i]),r=(new pR).apply([i]),o=a.apply([2*i]);return ZE(ZE(n,r),o)},t}(lR)).className="CustomInit",t)}else n=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,n,this.biasRegularizer,!0,this.biasConstraint)}else this.bias=null;this.built=!0},n.call=function(e,t){var n=this;return dx((function(){var r=null!=t.training&&t.training;if(3!==(e=e).length)throw new XC("LSTMCell expects 3 input Tensors (inputs, h, c), got "+e.length+".");var a=e[1],i=e[2];e=e[0],0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=zF({ones:function(){return Xk(e)},rate:n.dropout,training:r,count:4})),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=zF({ones:function(){return Xk(a)},rate:n.recurrentDropout,training:r,count:4}));var o,s,u,l,c=n.dropoutMask,p=n.recurrentDropoutMask;0<n.dropout&&n.dropout<1&&(e=Nx(e,c[0]));var h=eR(e,n.kernel.read());0<n.recurrentDropout&&n.recurrentDropout<1&&(a=Nx(a,p[0])),h=xx(h,eR(a,n.recurrentKernel.read())),n.useBias&&(h=aR(h,n.bias.read()));var f=YN(h,4,h.rank-1),d=f[0],m=f[1],v=f[2],g=f[3];o=n.recurrentActivation.apply(d),s=n.recurrentActivation.apply(m),u=xx(Nx(s,i),Nx(o,n.activation.apply(v))),l=n.recurrentActivation.apply(g);var y=Nx(l,n.activation.apply(u));return[y,y,u]}))},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={units:this.units,activation:HD(this.activation),recurrentActivation:HD(this.recurrentActivation),useBias:this.useBias,kernelInitializer:CR(this.kernelInitializer),recurrentInitializer:CR(this.recurrentInitializer),biasInitializer:CR(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:QD(this.kernelRegularizer),recurrentRegularizer:QD(this.recurrentRegularizer),biasRegularizer:QD(this.biasRegularizer),activityRegularizer:QD(this.activityRegularizer),kernelConstraint:wE(this.kernelConstraint),recurrentConstraint:wE(this.recurrentConstraint),biasConstraint:wE(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation};return Object.assign({},t,n)},t}(RF);OF.className="LSTMCell",ax(OF);var MF=function(e){function t(t){return 0===t.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),t.cell=new OF(t),e.call(this,t)||this}return qm(t,e),t.prototype.call=function(t,n){var r=this;return dx((function(){null!=r.cell.dropoutMask&&(mx(r.cell.dropoutMask),r.cell.dropoutMask=null),null!=r.cell.recurrentDropoutMask&&(mx(r.cell.recurrentDropoutMask),r.cell.recurrentDropoutMask=null);var a=null==n?null:n.mask,i=null==n?null:n.training,o=null==n?null:n.initialState;return e.prototype.call.call(r,t,{mask:a,training:i,initialState:o})}))},t.fromConfig=function(e,t){return 0===t.implmentation&&(t.implementation=1),new e(t)},t}(EF);MF.className="LSTM",ax(MF);var LF=function(e){function t(t){var n;return(n=e.call(this,t)||this).cells=t.cells,n}qm(t,e);var n=t.prototype;return n.call=function(e,t){var n=this;return dx((function(){for(var r,a=(e=e).slice(1),i=[],o=tv(n.cells.slice().reverse());!(r=o()).done;){var s=r.value;Array.isArray(s.stateSize)?i.push(a.splice(0,s.stateSize.length)):i.push(a.splice(0,1))}i.reverse();for(var u,l=[],c=0;c<n.cells.length;++c){var p=n.cells[c];a=i[c],u=0===c?[e[0]].concat(a):[u[0]].concat(a),u=p.call(u,t),l.push(u.slice(1))}a=[];for(var h,f=tv(l.slice().reverse());!(h=f()).done;){var d,m=h.value;(d=a).push.apply(d,m)}return[u[0]].concat(a)}))},n.build=function(e){var t;OR(e)&&(e=e[0]),e=e,this.cells.forEach((function(n,r){ME("RNNCell_"+r,(function(){n.build(e),t=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,e=[e[0],t]}))})),this.built=!0},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={cells:this.cells.map((function(e){return{className:e.getClassName(),config:e.getConfig()}}))};return Object.assign({},t,n)},t.fromConfig=function(e,t,n){void 0===n&&(n={});for(var r,a=[],i=tv(t.cells);!(r=i()).done;){var o=r.value;a.push(uA(o,n))}return new e({cells:a})},n.getWeights=function(){for(var e,t=[],n=tv(this.cells);!(e=n()).done;){var r=e.value;t.push.apply(t,r.weights)}return WR(t)},n.setWeights=function(e){for(var t,n=[],r=tv(this.cells);!(t=r()).done;)for(var a=t.value,i=a.weights.length,o=e.splice(i),s=0;s<a.weights.length;++s)n.push([a.weights[s],o[s]]);VR(n)},Hm(t,[{key:"stateSize",get:function(){for(var e,t=[],n=tv(this.cells.slice().reverse());!(e=n()).done;){var r=e.value;Array.isArray(r.stateSize)?t.push.apply(t,r.stateSize):t.push(r.stateSize)}return t}},{key:"trainableWeights",get:function(){if(!this.trainable)return[];for(var e,t=[],n=tv(this.cells);!(e=n()).done;){var r=e.value;t.push.apply(t,r.trainableWeights)}return t}},{key:"nonTrainableWeights",get:function(){for(var e,t=[],n=tv(this.cells);!(e=n()).done;){var r=e.value;t.push.apply(t,r.nonTrainableWeights)}if(!this.trainable){for(var a,i=[],o=tv(this.cells);!(a=o()).done;){var s=a.value;i.push.apply(i,s.trainableWeights)}return i.concat(t)}return t}}]),t}(RF);function zF(e){var t=e.ones,n=e.rate,r=e.training,a=void 0!==r&&r,i=e.count,o=void 0===i?1:i,s=function(){return iR(t(),n)},u=function(){return oR(s,t,a)};return!o||o<=1?vx(u().clone()):Array(o).fill(void 0).map(u).map((function(e){return vx(e.clone())}))}LF.className="StackedRNNCells",ax(LF);var PF=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]])}return n},BF=function(e){function t(t){var n;if(t.unroll)throw new YC("Unrolling is not possible with convolutional RNNs.");if(Array.isArray(t.cell))throw new YC("It is not possible at the moment to stack convolutional cells.");return(n=e.call(this,t)||this).inputSpec=[new UR({ndim:5})],n}qm(t,e);var n=t.prototype;return n.call=function(t,n){var r=this;return dx((function(){if(null!=r.cell.dropoutMask&&(mx(r.cell.dropoutMask),r.cell.dropoutMask=null),null!=r.cell.recurrentDropoutMask&&(mx(r.cell.recurrentDropoutMask),r.cell.recurrentDropoutMask=null),n&&n.constants)throw new XC("ConvRNN2D cell does not support constants");var a=null==n?null:n.mask,i=null==n?null:n.training,o=null==n?null:n.initialState;return e.prototype.call.call(r,t,{mask:a,training:i,initialState:o})}))},n.computeOutputShape=function(e){var t=this.computeSingleOutputShape(e);return this.returnSequences||(t=[t[0]].concat(t.slice(2))),this.returnState&&(t=[t].concat(Array(2).fill([e[0]].concat(t.slice(-3))))),t},n.getInitialState=function(e){var t=this;return dx((function(){var n=t.cell.stateSize,r=e.shape,a=t.computeSingleOutputShape(r),i=qk([a[0]].concat(a.slice(2)));return Array.isArray(n)?Array(n.length).fill(i):[i]}))},n.resetStates=function(e,t){var n=this;void 0===t&&(t=!1),dx((function(){if(!n.stateful)throw new qC("Cannot call resetStates() on an RNN Layer that is not stateful.");var r=n.inputSpec[0].shape,a=n.computeSingleOutputShape(r),i=[a[0]].concat(a.slice(2));if(null==r[0])throw new XC("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==n.getStates())Array.isArray(n.cell.stateSize)?n.states_=n.cell.stateSize.map((function(){return qk(i)})):n.states_=[qk(i)];else if(null==e)mx(n.states_),null!=n.keptStates&&(mx(n.keptStates),n.keptStates=[]),Array.isArray(n.cell.stateSize)?n.states_=n.cell.stateSize.map((function(){return qk(i)})):n.states_[0]=qk(i);else{if(Array.isArray(e)||(e=[e]),e.length!==n.states_.length)throw new XC("Layer "+n.name+" expects "+n.states_.length+" state(s), but it received "+e.length+" state value(s). Input received: "+e);t?n.keptStates.push(n.states_.slice()):mx(n.states_);for(var o=0;o<n.states_.length;++o){var s=e[o],u=i;if(!dv(s.shape,u))throw new XC("State "+o+" is incompatible with layer "+n.name+": expected shape="+u+", received shape="+s.shape);n.states_[o]=s}}n.states_=n.states_.map((function(e){return vx(e.clone())}))}))},n.computeSingleOutputShape=function(e){var t=this.cell,n=t.dataFormat,r=t.filters,a=t.kernelSize,i=t.padding,o=t.strides,s=t.dilationRate,u="channelsFirst"===n,l=e[u?3:2],c=e[u?4:3],p=uF(l,a[0],i,o[0],s[0]),h=uF(c,a[1],i,o[1],s[1]);return[].concat(e.slice(0,2),u?[r,p,h]:[p,h,r])},t}(EF);BF.className="ConvRNN2D";var WF=function(e){function t(t){var n,r=t.filters,a=t.kernelSize,i=t.strides,o=t.padding,s=t.dataFormat,u=t.dilationRate;return(n=e.call(this,Object.assign({},t,{units:r}))||this).filters=r,hE(n.filters,"filters"),n.kernelSize=sF(a,2,"kernelSize"),n.kernelSize.forEach((function(e){return hE(e,"kernelSize")})),n.strides=sF(i||1,2,"strides"),n.strides.forEach((function(e){return hE(e,"strides")})),n.padding=o||"valid",FE(n.padding),n.dataFormat=s||"channelsLast",DE(n.dataFormat),n.dilationRate=sF(u||1,2,"dilationRate"),n.dilationRate.forEach((function(e){return hE(e,"dilationRate")})),n}qm(t,e);var n=t.prototype;return n.build=function(e){var t;e=zR(e);var n="channelsFirst"===this.dataFormat?1:e.length-1;if(null==e[n])throw new XC("The channel dimension of the input should be defined. Found "+e[n]);var r=e[n],a=this.kernelSize.concat([r,4*this.filters]);this.kernel=this.addWeight("kernel",a,null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint);var i=this.kernelSize.concat([this.filters,4*this.filters]);if(this.recurrentKernel=this.addWeight("recurrent_kernel",i,null,this.recurrentInitializer,this.recurrentRegularizer,!0,this.recurrentConstraint),this.useBias){var o;if(this.unitForgetBias){var s=this.biasInitializer,u=this.filters;o=new((t=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.apply=function(e,t){return JE([s.apply([u]),Kk([u]),s.apply([2*u])])},t}(lR)).className="CustomInit",t)}else o=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.filters],null,o,this.biasRegularizer,!0,this.biasConstraint)}this.built=!0},n.call=function(e,t){var n=this;return dx((function(){if(3!==e.length)throw new XC("ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got "+e.length+".");var r=t.training||!1,a=e[0],i=e[1],o=e[2];0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=zF({ones:function(){return Xk(a)},rate:n.dropout,training:r,count:4}));var s=n.dropoutMask,u=function(e,t,n){return t&&t[n]?Nx(t[n],e):e},l=u(a,s,0),c=u(a,s,1),p=u(a,s,2),h=u(a,s,3);0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=zF({ones:function(){return Xk(i)},rate:n.recurrentDropout,training:r,count:4}));var f=n.recurrentDropoutMask,d=u(i,f,0),m=u(i,f,1),v=u(i,f,2),g=u(i,f,3),y=YN(n.kernel.read(),4,3),b=y[0],x=y[1],w=y[2],k=y[3],N=n.useBias?YN(n.bias.read(),4):[null,null,null,null],I=N[0],S=N[1],T=N[2],C=N[3];l=n.inputConv(l,b,I,n.padding),c=n.inputConv(c,x,S,n.padding),p=n.inputConv(p,w,T,n.padding),h=n.inputConv(h,k,C,n.padding);var E=YN(n.recurrentKernel.read(),4,3),R=E[0],A=E[1],D=E[2],F=E[3];d=n.recurrentConv(d,R),m=n.recurrentConv(m,A),v=n.recurrentConv(v,D),g=n.recurrentConv(g,F);var _=n.recurrentActivation.apply(xx(l,d)),O=n.recurrentActivation.apply(xx(c,m)),M=xx(Nx(O,o),Nx(_,n.activation.apply(xx(p,v)))),L=Nx(n.recurrentActivation.apply(xx(h,g)),n.activation.apply(M));return[L,L,M]}))},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n=(t.units,PF(t,["units"])),r={filters:this.filters,kernelSize:this.kernelSize,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,strides:this.strides};return Object.assign({},n,r)},n.inputConv=function(e,t,n,r){var a=gw(e,t,this.strides,r||"valid","channelsFirst"===this.dataFormat?"NCHW":"NHWC",this.dilationRate);return n?aR(a,n,this.dataFormat):a},n.recurrentConv=function(e,t){return gw(e,t,1,"same","channelsFirst"===this.dataFormat?"NCHW":"NHWC")},t}(OF);WF.className="ConvLSTM2DCell",ax(WF);var VF=function(e){function t(t){var n=new WF(t);return e.call(this,Object.assign({},t,{cell:n}))||this}return qm(t,e),t.fromConfig=function(e,t){return new e(t)},t}(BF);VF.className="ConvLSTM2D",ax(VF);var UF=function(e){function t(t){var n;return(n=e.call(this,t)||this).rate=Math.max(Math.min(t.rate,1),0),n.noiseShape=t.noiseShape,n.seed=t.seed,n.supportsMasking=!0,n}qm(t,e);var n=t.prototype;return n.getNoiseShape=function(e){if(null==this.noiseShape)return this.noiseShape;for(var t=e.shape,n=[],r=0;r<this.noiseShape.length;++r)n.push(null==this.noiseShape[r]?t[r]:this.noiseShape[r]);return n},n.call=function(e,t){var n=this;return dx((function(){n.invokeCallHook(e,t);var r=LR(e);if(0<n.rate&&n.rate<1){var a=null!=t.training&&t.training,i=n.getNoiseShape(r);return oR((function(){return iR(r,n.rate,i,n.seed)}),(function(){return r}),a)}return e}))},n.getConfig=function(){var t={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},n.dispose=function(){return e.prototype.dispose.call(this)},t}(KR);UF.className="Dropout",ax(UF);var GF=function(e){function t(t){var n;return(n=e.call(this,t)||this).inputSpec=[{ndim:3}],n}return qm(t,e),t.prototype.getNoiseShape=function(e){var t=e.shape;return[t[0],1,t[2]]},t}(UF);GF.className="SpatialDropout1D",ax(GF);var jF=function(e){function t(t){var n;if((n=e.call(this,t)||this).activation=null,n.useBias=!0,n.kernel=null,n.bias=null,n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_BIAS_INITIALIZER="zeros",null==t.batchInputShape&&null==t.inputShape&&null!=t.inputDim){var r=null;null!=t.batchSize&&(r=t.batchSize),n.batchInputShape=[r,t.inputDim]}return n.units=t.units,hE(n.units,"units"),n.activation=KD(t.activation),null!=t.useBias&&(n.useBias=t.useBias),n.kernelInitializer=ER(t.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.biasInitializer=ER(t.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelConstraint=NE(t.kernelConstraint),n.biasConstraint=NE(t.biasConstraint),n.kernelRegularizer=eF(t.kernelRegularizer),n.biasRegularizer=eF(t.biasRegularizer),n.activityRegularizer=eF(t.activityRegularizer),n.supportsMasking=!0,n.inputSpec=[{minNDim:2}],n}qm(t,e);var n=t.prototype;return n.build=function(e){var t,n=(e=zR(e))[e.length-1];null==this.kernel&&(this.kernel=this.addWeight("kernel",[n,this.units],null,this.kernelInitializer,this.kernelRegularizer,!0,this.kernelConstraint),this.useBias&&(this.bias=this.addWeight("bias",[this.units],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint))),this.inputSpec=[{minNDim:2,axes:(t={},t[-1]=n,t)}],this.built=!0},n.computeOutputShape=function(e){var t=(e=zR(e)).slice();return t[t.length-1]=this.units,t},n.call=function(e,t){var n=this;return dx((function(){n.invokeCallHook(e,t);var r,a=LR(e),i=fE(n.activation.getClassName());return null!=i?r=eR(a,n.kernel.read(),i,n.bias?n.bias.read():null):(r=eR(a,n.kernel.read()),null!=n.bias&&(r=aR(r,n.bias.read())),null!=n.activation&&(r=n.activation.apply(r))),r}))},n.getConfig=function(){var t={units:this.units,activation:HD(this.activation),useBias:this.useBias,kernelInitializer:CR(this.kernelInitializer),biasInitializer:CR(this.biasInitializer),kernelRegularizer:QD(this.kernelRegularizer),biasRegularizer:QD(this.biasRegularizer),activityRegularizer:QD(this.activityRegularizer),kernelConstraint:wE(this.kernelConstraint),biasConstraint:wE(this.biasConstraint)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);jF.className="Dense",ax(jF);var HF=function(e){function t(t){var n;return t=t||{},(n=e.call(this,t)||this).inputSpec=[{minNDim:3}],n.dataFormat=t.dataFormat,n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){for(var t,n=tv((e=zR(e)).slice(1));!(t=n()).done;){if(null==t.value)throw new XC('The shape of the input to "Flatten" is not fully defined (got '+e.slice(1)+'). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.')}return[e[0],WE(e,1)]},n.call=function(e,t){var n=this;return dx((function(){n.invokeCallHook(e,t);var r=LR(e);if("channelsFirst"===n.dataFormat&&r.rank>1){for(var a=[0],i=2;i<r.rank;++i)a.push(i);a.push(1),r=r.transpose(a)}return function(e){if(e.rank<=1)throw new XC("batchFlatten requires a minimum rank of 2. Got rank: "+e.rank+".");var t=[e.shape[0],WE(e.shape,1)];return e.reshape(t)}(r)}))},n.getConfig=function(){var t={};null!=this.dataFormat&&(t.dataFormat=this.dataFormat);var n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);HF.className="Flatten",ax(HF);var qF=function(e){function t(t){var n;return(n=e.call(this,t)||this).supportsMasking=!0,n.activation=KD(t.activation),n}qm(t,e);var n=t.prototype;return n.call=function(e,t){var n=this;return dx((function(){n.invokeCallHook(e,t);var r=LR(e);return n.activation.apply(r)}))},n.getConfig=function(){var t={activation:HD(this.activation)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);qF.className="Activation",ax(qF);var KF=function(e){function t(t){var n;return(n=e.call(this,t)||this).n=t.n,n.inputSpec=[{ndim:2}],n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return[e[0],this.n,e[1]]},n.call=function(e,t){var n=this;return dx((function(){return e=LR(e),t=e,r=n.n,dx((function(){if(2!==t.shape.length)throw new XC("repeat() expects a rank-2 tensor, but received a rank-"+t.shape.length+" tensor.");return QE(qE(t,1),[1,r,1])}));var t,r}))},n.getConfig=function(){var t={n:this.n},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);KF.className="RepeatVector",ax(KF);var XF=function(e){function t(t){var n;(n=e.call(this,t)||this).targetShape=t.targetShape;for(var r=0;r<n.targetShape.length;++r)n.isUnknown(n.targetShape[r])&&(n.targetShape[r]=null);return n}qm(t,e);var n=t.prototype;return n.isUnknown=function(e){return e<0||null==e},n.fixUnknownDimension=function(e,t){for(var n="Total size of new array must be unchanged.",r=t.slice(),a=1,i=null,o=0;o<r.length;++o){var s=r[o];if(this.isUnknown(s)){if(null!==i)throw new XC("Can only specifiy one unknown dimension.");i=o}else a*=s}var u=WE(e);if(null!==i){if(0===a||u%a!=0)throw new XC(n);r[i]=u/a}else if(u!==a)throw new XC(n);return r},n.computeOutputShape=function(e){for(var t=!1,n=0;n<e.length;++n)if(this.isUnknown(e[n])){t=!0;break}return t?e.slice(0,1).concat(this.targetShape):e.slice(0,1).concat(this.fixUnknownDimension(e.slice(1),this.targetShape))},n.call=function(e,t){var n=this;return dx((function(){n.invokeCallHook(e,t);var r=LR(e),a=r.shape,i=a.slice(0,1).concat(n.fixUnknownDimension(a.slice(1),n.targetShape));return r.reshape(i)}))},n.getConfig=function(){var t={targetShape:this.targetShape},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);XF.className="Reshape",ax(XF);var YF=function(e){function t(t){var n;if(n=e.call(this,t)||this,null==t.dims)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(t.dims))throw new Error("Permute constructor requires `dims` to be an Array, but received "+t.dims+" instead.");var r=jE(1,t.dims.length+1);if(!dv(t.dims.slice().sort(),r))throw new Error("Invalid permutation `dims`: "+JSON.stringify(t.dims)+" `dims` must contain consecutive integers starting from 1.");return n.dims=t.dims,n.dimsIncludingBatch=[0].concat(n.dims),n.inputSpec=[new UR({ndim:n.dims.length+1})],n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){var t=(e=zR(e)).slice();return this.dims.forEach((function(n,r){t[r+1]=e[n]})),t},n.call=function(e,t){return Tb(LR(e),this.dimsIncludingBatch)},n.getConfig=function(){var t={dims:this.dims},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);YF.className="Permute",ax(YF);var JF=function(e){function t(t){var n;return(n=e.call(this,null==t?{}:t)||this).supportsMasking=!0,n.maskValue=null!=t?null==t.maskValue?0:t.maskValue:0,n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return e},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={maskValue:this.maskValue};return Object.assign(n,t),n},n.computeMask=function(e,t){var n=LR(e);return Rx(Hk(n,this.maskValue),-1)},n.call=function(e,t){var n=this;return dx((function(){n.invokeCallHook(e,t);var r=LR(e),a=Rx(Hk(r,n.maskValue),-1,!0);return r.mul(a.asType(r.dtype))}))},t}(KR);JF.className="Masking",ax(JF);var ZF=function(e){function t(t){var n;if((n=e.call(this,t)||this).embeddings=null,n.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==t.batchInputShape&&null==t.inputShape){var r=null;null!=t.batchSize&&(r=t.batchSize),null==t.inputLength?n.batchInputShape=[r,null]:n.batchInputShape=[r].concat(tE(t.inputLength))}return n.inputDim=t.inputDim,hE(n.inputDim,"inputDim"),n.outputDim=t.outputDim,hE(n.outputDim,"outputDim"),n.embeddingsInitializer=ER(t.embeddingsInitializer||n.DEFAULT_EMBEDDINGS_INITIALIZER),n.embeddingsRegularizer=eF(t.embeddingsRegularizer),n.activityRegularizer=eF(t.activityRegularizer),n.embeddingsConstraint=NE(t.embeddingsConstraint),n.maskZero=t.maskZero,n.supportsMasking=t.maskZero,n.inputLength=t.inputLength,n}qm(t,e);var n=t.prototype;return n.build=function(e){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0},n.warnOnIncompatibleInputShape=function(e){},n.computeMask=function(e,t){var n=this;return dx((function(){return n.maskZero?(e=LR(e),Hk(e,zw(e))):null}))},n.computeOutputShape=function(e){if(e=zR(e),null==this.inputLength)return[].concat(e,[this.outputDim]);var t=tE(this.inputLength);if(t.length!==e.length-1)throw new XC('"inputLength" is '+this.inputLength+", but received input shape has shape "+e);for(var n=0,r=0;r<t.length;++r){var a=t[r],i=e[r+1];if(null!=a&&null!=i&&a!==i)throw new XC('"inputLength" is '+this.inputLength+", but received input shape has shape "+e);null==a&&(t[n]=i),n++}return[e[0]].concat(t,[this.outputDim])},n.call=function(e,t){var n=this;return dx((function(){n.invokeCallHook(e,t);var r=LR(e);return"int32"!==r.dtype&&(r=HE(r,"int32")),tR(n.embeddings.read(),r.as1D()).reshape(zR(n.computeOutputShape(r.shape)))}))},n.getConfig=function(){var t={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:CR(this.embeddingsInitializer),embeddingsRegularizer:QD(this.embeddingsRegularizer),activityRegularizer:QD(this.activityRegularizer),embeddingsConstraint:wE(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);ZF.className="Embedding",ax(ZF);var QF=function(e){function t(t){var n;return(n=e.call(this,t||{})||this).supportsMasking=!0,n}qm(t,e);var n=t.prototype;return n.mergeFunction=function(e){throw new YC},n.computeElementwiseOpOutputShape=function(e,t){if(null==e||null==t)return null;if(e.length<t.length)return this.computeElementwiseOpOutputShape(t,e);if(0===t.length)return e;for(var n=e.slice(0,e.length-t.length),r=0;r<t.length;++r){var a=e[e.length-t.length+r],i=t[r];if(null==a||null==i||a<0||i<0)n.push(null);else if(1===a)n.push(i);else if(1===i)n.push(a);else{if(a!==i)throw new XC("Operands could not be broadcast together with shapes "+JSON.stringify(e)+" "+JSON.stringify(t));n.push(a)}}return n},n.build=function(e){if(Array.isArray(e)&&!Array.isArray(e[0])&&(e=[zR(e)]),(e=e).length<2)throw new XC("A merge layer should be called on an Array of at least 2 inputs. Got "+e.length+" input(s).");for(var t,n=[],r=tv(e);!(t=r()).done;){var a=t.value;null!=a&&null!==a[0]&&n.push(a[0])}if((n=uE(n)).length>1)throw new XC("Can not merge tensors with different batch sizes. Got tensors with shapes: "+JSON.stringify(e)+".");for(var i=null==e[0]?null:e[0].slice(1),o=1;o<e.length;++o){var s=null==e[o]?null:e[o].slice(1);i=this.computeElementwiseOpOutputShape(i,s)}var u=e.map((function(e){return e.length}));-1===e.indexOf(null)&&1===uE(u).length?this.reshapeRequired=!1:this.reshapeRequired=!0},n.call=function(e,t){var n=this;return dx((function(){if(e=e,n.reshapeRequired){var t=[],r=e.map((function(e){return e.rank}));if(-1===r.indexOf(null)){for(var a,i=GE(r),o=tv(e);!(a=o()).done;){for(var s=a.value,u=s.rank,l=0;l<i-u;++l)s=qE(s,1);t.push(s)}return n.mergeFunction(t)}for(var c,p=!1,h=tv(e);!(c=h()).done;){var f=c.value,d=f.rank;if(null==d){var m=f.shape,v=m[0],g=m.slice(1).concat([v]),y=f.reshape([v].concat(WE(m.slice(1))));y=(y=Tb(y,[1,0])).reshape(g),t.push(y),p=!0}else if(d>1){var b=jE(1,d).concat([0]);t.push(Tb(f,b)),p=!0}else t.push(f)}var x=n.mergeFunction(t),w=x.rank;if(p)if(null==w){var k=x.shape,N=k[k.length-1],I=[N].concat(k.slice(0,k.length-1));x=Tb(x.reshape([-1,N]),[1,0]).reshape(I)}else if(w>1){var S=[w-1].concat(jE(0,w-1));x=Tb(x,S)}return x}return n.mergeFunction(e)}))},n.computeOutputShape=function(e){var t;t=null==(e=e)[0]?null:e[0].slice(1);for(var n=1;n<e.length;++n){var r=null==e[n]?null:e[n].slice(1);t=this.computeElementwiseOpOutputShape(t,r)}for(var a,i=[],o=tv(e);!(a=o()).done;){var s=a.value;null!=s&&null!==s[0]&&i.push(s[0])}return t=1===(i=uE(i)).length?i.concat(t):[null].concat(t)},n.computeMask=function(e,t){return dx((function(){if(null==t)return null;if(!Array.isArray(t))throw new XC("`mask` should be an Array");if(!Array.isArray(e))throw new XC("`inputs` should be an Array");if(t.length!==e.length)throw new XC("The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths ("+e.length+" vs "+t.length+")");if(t.every((function(e){return null==e})))return null;for(var n=(t=t.map((function(e){return null==e?e:Gw(e,0)})))[0],r=1;r<t.length-1;++r)n=Ek(n,t[r]);return n}))},t}(KR),$F=function(e){function t(t){return e.call(this,t)||this}return qm(t,e),t.prototype.mergeFunction=function(e){return dx((function(){for(var t=e[0].clone(),n=1;n<e.length;++n)t=xx(t,e[n]);return t}))},t}(QF);$F.className="Add",ax($F);var e_=function(e){function t(t){return e.call(this,t)||this}return qm(t,e),t.prototype.mergeFunction=function(e){return dx((function(){for(var t=e[0].clone(),n=1;n<e.length;++n)t=Nx(t,e[n]);return t}))},t}(QF);e_.className="Multiply",ax(e_);var t_=function(e){function t(t){return e.call(this,t)||this}return qm(t,e),t.prototype.mergeFunction=function(e){return dx((function(){for(var t=e[0].clone(),n=1;n<e.length;++n)t=xx(t,e[n]);return Nx(1/e.length,t)}))},t}(QF);t_.className="Average",ax(t_);var n_=function(e){function t(t){return e.call(this,t)||this}return qm(t,e),t.prototype.mergeFunction=function(e){return dx((function(){for(var t=e[0],n=1;n<e.length;++n)t=Mk(t,e[n]);return t}))},t}(QF);n_.className="Maximum",ax(n_);var r_=function(e){function t(t){return e.call(this,t)||this}return qm(t,e),t.prototype.mergeFunction=function(e){return dx((function(){for(var t=e[0],n=1;n<e.length;++n)t=Pk(t,e[n]);return t}))},t}(QF);r_.className="Minimum",ax(r_);var a_=function(e){function t(t){var n;return(n=e.call(this,t)||this).DEFAULT_AXIS=-1,null==t&&(t={}),n.axis=null==t.axis?n.DEFAULT_AXIS:t.axis,n.supportsMasking=!0,n.reshapeRequired=!1,n}qm(t,e);var n=t.prototype;return n.build=function(e){if(!Array.isArray(e)||!Array.isArray(e[0])||1===e.length)throw new XC("A `Concatenate` layer should be called on a list of at least 2 inputs");for(var t,n=!0,r=tv(e=e);!(t=r()).done;){if(null!=t.value){n=!1;break}}if(!n){for(var a=[],i=0;i<e.length;++i){var o=e[i].slice();o.splice(this.axis,1);for(var s,u=!1,l=tv(a);!(s=l()).done;){if(dv(s.value,o)){u=!0;break}}u||a.push(o)}if(a.length>1)throw new XC("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(e))}},n.mergeFunction=function(e){var t=this;return dx((function(){return JE(e,t.axis)}))},n.computeOutputShape=function(e){if(!Array.isArray(e)||!Array.isArray(e[0]))throw new XC("A `Concatenate` layer should be called on a list of inputs.");for(var t,n=e,r=n[0].slice(),a=this.axis<0?r.length+this.axis:this.axis,i=tv(n.slice(1));!(t=i()).done;){var o=t.value;if(null==r[a]||null==o[a]){r[a]=null;break}r[a]+=o[a]}return r},n.computeMask=function(e,t){var n=this;if(null==t)return null;if(!Array.isArray(t))throw new XC("`mask` should be an array for Concatenate");if(!Array.isArray(e))throw new XC("`inputs` should be an array for Concatenate");if(t.length!==e.length)throw new XC("Mismatch in the length of mask ("+t.length+") and the legnth of inputs ("+e.length+")");return dx((function(){var r=!0;if(t.forEach((function(e){null==e||(r=!1)})),r)return null;for(var a=[],i=0;i<e.length;++i)null==t[i]?a.push(Xk(e[i]).asType("bool")):t[i].rank<e[i].rank?a.push(Gw(t[i],-1)):a.push(t[i]);var o=$x(a,n.axis);return Ex(o,-1,!1)}))},n.getConfig=function(){var t={axis:this.axis},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(QF);function i_(e,t){for(;e<0;)e+=t;return e}a_.className="Concatenate",ax(a_);var o_=function(e){function t(t){var n;return(n=e.call(this,t)||this).axes=t.axes,n.normalize=null!=t.normalize&&t.normalize,n.supportsMasking=!0,n.reshapeRequired=!1,n}qm(t,e);var n=t.prototype;return n.build=function(e){lv(Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&Array.isArray(e[1]),(function(){return"A `Dot` layer should be called on a list of exactly 2 inputs."}));var t=e[0],n=e[1];if(t.length>3||n.length>3)throw new YC("Dot layer does not support tensors of 4D or higher rank yet.");var r=this.interpretAxes(t,n);if(t[r[0]]!==n[r[1]])throw new XC("Dimension incompatibility: "+t[r[0]]+" !== "+n[r[1]])},n.mergeFunction=function(e){if(2!==e.length)throw new XC("A `Dot` layer must be called on exactly 2 inputs, but received "+e.length+" input(s).");var t,n=e[0],r=e[1];return t=Array.isArray(this.axes)?this.axes.map((function(t,n){return i_(t,e[n].shape.length)})):[i_(this.axes,n.shape.length),i_(this.axes,r.shape.length)],this.normalize&&(n=lA(n,t[0]),r=lA(r,t[1])),function(e,t,n){if(e.shape.length>3||t.shape.length>3)throw new YC("batchDot is not implemented for tensors of 4D or higher rank yet");if(lv(e.shape.length>=2,(function(){return"batchDot requires the rank of x to be >= 2, but got "+e.shape.length})),lv(e.shape.length>=2,(function(){return"batchDot requires the rank of y to be >= 2, but got "+t.shape.length})),"number"==typeof n&&(n=[n,n]),"complex64"===e.dtype||"complex64"===t.dtype)throw new YC("batchDot is not implemented for complex64-type Tensors yet.");var r=e.shape.length,a=t.shape.length;null==n&&(n=[r-1,a-2]);var i=n;return dx((function(){var n,o;if(r>a){n=r-a;for(var s=[],u=0;u<n;++u)s.push(1);t=t.reshape(t.shape.concat(s))}else if(a>r){n=a-r;for(var l=[],c=0;c<n;++c)l.push(1);e=e.reshape(e.shape.concat(l))}else n=0;if(2===e.shape.length&&2===t.shape.length)o=i[0]===i[1]?e.mul(t).sum(i[0]):e.transpose([1,0]).mul(t).sum(i[1]);else{var p=i[0]!==e.shape.length-1,h=i[1]===t.shape.length-1;o=e.matMul(t,p,h)}if(n>0){for(var f,d=[],m=f=r>a?r+a-3:r-1;m<f+n;++m)d.push(m);o=o.squeeze(d)}return 1===o.shape.length&&(o=o.expandDims(1)),o}))}(n,r,t)},n.interpretAxes=function(e,t){return Array.isArray(this.axes)?this.axes:[i_(this.axes,e.length),i_(this.axes,t.length)]},n.computeOutputShape=function(e){lv(Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&Array.isArray(e[1]),(function(){return"A `Dot` layer should be called on a list of exactly 2 inputs."}));var t=e[0].slice(),n=e[1].slice();if(t.length>3||n.length>3)throw new YC("Dot layer does not support tensors of 4D or higher rank yet.");var r=this.interpretAxes(t,n);t.splice(r[0],1),n.splice(r[1],1),n.splice(0,1);var a=t.concat(n);return 1===a.length&&a.push(1),a},n.computeMask=function(e,t){return null},n.getConfig=function(){var t={axes:this.axes,normalize:this.normalize},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(QF);o_.className="Dot",ax(o_);var s_=function(e){function t(t){var n;return(n=e.call(this,t)||this).supportsMasking=!0,n.stddev=t.stddev,n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return e},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={stddev:this.stddev};return Object.assign(n,t),n},n.call=function(e,t){var n=this;return dx((function(){n.invokeCallHook(e,t);var r=LR(e);return oR((function(){return $E(r.shape,0,n.stddev).add(r)}),(function(){return r}),t.training||!1)}))},t}(KR);s_.className="GaussianNoise",ax(s_);var u_=function(e){function t(t){var n;return(n=e.call(this,t)||this).supportsMasking=!0,n.rate=t.rate,n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return e},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={rate:this.rate};return Object.assign(n,t),n},n.call=function(e,t){var n=this;return dx((function(){n.invokeCallHook(e,t);var r=LR(e);if(n.rate>0&&n.rate<1){return oR((function(){var e=Math.sqrt(n.rate/(1-n.rate));return r.mul($E(r.shape,1,e))}),(function(){return r}),t.training||!1)}return r}))},t}(KR);u_.className="GaussianDropout",ax(u_);var l_=function(e){function t(t){var n;return(n=e.call(this,t)||this).supportsMasking=!0,n.rate=t.rate,n.noiseShape=t.noiseShape,n}qm(t,e);var n=t.prototype;return n._getNoiseShape=function(e){return this.noiseShape||LR(e).shape},n.computeOutputShape=function(e){return e},n.getConfig=function(){var t=e.prototype.getConfig.call(this),n={rate:this.rate};return Object.assign(n,t),n},n.call=function(e,t){var n=this;return dx((function(){if(n.rate<1&&n.rate>0){var r=n._getNoiseShape(e);return oR((function(){var t=LR(e),a=-1.7580993408473766,i=Zw(xN(r),n.rate);i=HE(i,"float32");var o=Math.pow((1-n.rate)*(1+n.rate*Math.pow(a,2)),-.5),s=-o*a*n.rate;return t.mul(i).add(i.add(-1).mul(a)).mul(o).add(s)}),(function(){return LR(e)}),t.training||!1)}return e}))},t}(KR);function c_(e,t,n,r,a,i){var o;if(void 0===i&&(i=.001),2===e.rank)o=ow(e,t,n,r,a,i);else if(3===e.rank)o=sw(e,t,n,r,a,i);else{if(4!==e.rank)throw new YC("batchNormalization is not implemented for array of rank "+e.rank+" yet");o=uw(e,t,n,r,a,i)}return o}function p_(e,t,n,r,a){return void 0===a&&(a=.001),dv(r.slice().sort(),jE(0,e.rank-1))?function(e,t,n,r,a){return void 0===a&&(a=.001),dx((function(){var i=Uk(e,r),o=i.mean,s=i.variance;return[c_(e,o,s,n,t,a),o,s]}))}(e,t,n,r,a):function(e,t,n,r,a){return void 0===a&&(a=.001),dx((function(){for(var i,o=Uk(e,r),s=o.mean,u=o.variance,l=[],c=tv(jE(0,e.rank));!(i=c()).done;){var p=i.value;-1!==r.indexOf(p)?l.push(1):l.push(e.shape[p])}var h=s.reshape(l),f=u.reshape(l),d=null==t?null:t.reshape(l),m=null==n?null:n.reshape(l);return[c_(e,h,f,m,d,a),s,u]}))}(e,t,n,r,a)}l_.className="AlphaDropout",ax(l_);var h_=function(e){function t(t){var n;return null==t&&(t={}),(n=e.call(this,t)||this).supportsMasking=!0,n.axis=null==t.axis?-1:t.axis,n.momentum=null==t.momentum?.99:t.momentum,n.epsilon=null==t.epsilon?.001:t.epsilon,n.center=null==t.center||t.center,n.scale=null==t.scale||t.scale,n.betaInitializer=ER(t.betaInitializer||"zeros"),n.gammaInitializer=ER(t.gammaInitializer||"ones"),n.movingMeanInitializer=ER(t.movingMeanInitializer||"zeros"),n.movingVarianceInitializer=ER(t.movingVarianceInitializer||"ones"),n.betaConstraint=NE(t.betaConstraint),n.gammaConstraint=NE(t.gammaConstraint),n.betaRegularizer=eF(t.betaRegularizer),n.gammaRegularizer=eF(t.gammaRegularizer),n}qm(t,e);var n=t.prototype;return n.build=function(e){var t;e=zR(e);var n=this.axis>=0?this.axis:this.axis+e.length,r=e[n];if(null==r)throw new XC("Axis "+n+" of input tensor should have a defined dimension but the layer received an input with shape "+JSON.stringify(e)+".");this.inputSpec=[new UR({ndim:e.length,axes:(t={},t[n]=r,t)})];var a=[r];this.scale&&(this.gamma=this.addWeight("gamma",a,null,this.gammaInitializer,this.gammaRegularizer,!0,this.gammaConstraint)),this.center&&(this.beta=this.addWeight("beta",a,null,this.betaInitializer,this.betaRegularizer,!0,this.betaConstraint)),this.movingMean=this.addWeight("moving_mean",a,null,this.movingMeanInitializer,null,!1),this.movingVariance=this.addWeight("moving_variance",a,null,this.movingVarianceInitializer,null,!1),this.built=!0},n.call=function(e,t){var n=this;return dx((function(){var r=null!=t.training&&t.training,a=LR(e),i=a.shape,o=i.length,s=jE(0,o),u=n.axis>=0?n.axis:n.axis+o;s.splice(u,1);var l=ZC(1,o);l[u]=i[u];var c=s.slice();c.sort();var p=!dv(c,jE(0,o).slice(0,o-1));if(!r)return function(){if(p){var e=n.movingMean.read().reshape(l),t=n.movingVariance.read().reshape(l),r=n.center?n.beta.read().reshape(l):null,i=n.scale?n.gamma.read().reshape(l):null;return c_(a,e,t,r,i,n.epsilon)}return c_(a,n.movingMean.read(),n.movingVariance.read(),null==n.beta?null:n.beta.read(),null==n.gamma?null:n.gamma.read(),n.epsilon)}();var h=p_(a,n.gamma.read(),n.beta.read(),s,n.epsilon),f=h[0],d=h[1],m=h[2],v=function(e,t,n){dx((function(){var r=1-n,a=e.read(),i=a.sub(t).mul(r);e.write(a.sub(i))}))};return v(n.movingMean,d,n.momentum),v(n.movingVariance,m,n.momentum),f}))},n.getConfig=function(){var t={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:CR(this.betaInitializer),gammaInitializer:CR(this.gammaInitializer),movingMeanInitializer:CR(this.movingMeanInitializer),movingVarianceInitializer:CR(this.movingVarianceInitializer),betaRegularizer:QD(this.betaRegularizer),gammaRegularizer:QD(this.gammaRegularizer),betaConstraint:wE(this.betaConstraint),gammaConstraint:wE(this.gammaConstraint)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);h_.className="BatchNormalization",ax(h_);var f_=function(e){function t(t){var n;if(null==t&&(t={}),(n=e.call(this,t)||this).axis=null==t.axis?-1:t.axis,"number"==typeof n.axis){if(!Number.isInteger(n.axis))throw new Error("Expected axis to be an integer, but received "+n.axis)}else{if(!Array.isArray(n.axis))throw new Error("Expected axis to be an integer or an array of integers, but received "+JSON.stringify(n.axis));for(var r,a=tv(n.axis);!(r=a()).done;){var i=r.value;if(!Number.isInteger(i))throw new Error("Expected axis to be an array of integers, but received "+JSON.stringify(n.axis))}}return n.epsilon=null==t.epsilon?.001:t.epsilon,n.center=null==t.center||t.center,n.scale=null==t.scale||t.scale,n.betaInitializer=ER(t.betaInitializer||"zeros"),n.gammaInitializer=ER(t.gammaInitializer||"ones"),n.betaRegularizer=eF(t.betaRegularizer),n.gammaRegularizer=eF(t.gammaRegularizer),n.supportsMasking=!0,n}qm(t,e);var n=t.prototype;return n.build=function(e){var t=(e=zR(e)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(var n=0;n<this.axis.length;++n)this.axis[n]<0&&(this.axis[n]+=t);for(var r,a=tv(this.axis);!(r=a()).done;){var i=r.value;if(i<0||i>=t)throw new Error("Invalid axis: "+i)}if(this.axis.length!==uE(this.axis).length)throw new Error("Found duplicate axes in: "+this.axis);var o=this.axis.map((function(t){return e[t]}));this.scale?this.gamma=this.addWeight("gamma",o,"float32",this.gammaInitializer,this.gammaRegularizer,!0):this.gamma=null,this.center?this.beta=this.addWeight("beta",o,"float32",this.betaInitializer,this.betaRegularizer,!0):this.beta=null,this.built=!0},n.call=function(e,t){var n=this,r=LR(e),a=r.shape,i=a.length;return dx((function(){for(var e,t=Uk(r,n.axis,!0),o=t.mean,s=t.variance,u=ZC(1,i),l=tv(n.axis);!(e=l()).done;){var c=e.value;u[c]=a[c]}for(var p=function(e){return null!=e&&e.shape.length!==i&&n.axis!==[i-1]?e.reshape(u):e},h=p(n.gamma.read()),f=p(n.beta.read()),d=[],m=[],v=0;v<i;++v)-1!==n.axis.indexOf(v)?(d.push(a[v]),m.push(1)):(d.push(1),m.push(a[v]));return o=o.tile(d),s=s.tile(d),h=h.tile(m),f=f.tile(m),c_(r,o,s,f,h,n.epsilon)}))},n.getConfig=function(){var t={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:CR(this.betaInitializer),gammaInitializer:CR(this.gammaInitializer),betaRegularizer:QD(this.betaRegularizer),gammaRegularizer:QD(this.gammaRegularizer)},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);f_.className="LayerNormalization",ax(f_);var d_=function(e){function t(t){var n;if(null==t&&(t={}),(n=e.call(this,t)||this).dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,null==t.padding)n.padding=[[1,1],[1,1]];else if("number"==typeof t.padding)n.padding=[[t.padding,t.padding],[t.padding,t.padding]];else{if(t.padding=t.padding,2!==t.padding.length)throw new XC("ZeroPadding2D expects padding to be a length-2 array, but received a length-"+t.padding.length+" array.");var r,a;if("number"==typeof t.padding[0])r=[t.padding[0],t.padding[0]],a=[t.padding[1],t.padding[1]];else{if(t.padding=t.padding,2!==t.padding[0].length)throw new XC("ZeroPadding2D expects height padding to be a length-2 array, but received a length-"+t.padding[0].length+" array.");if(r=t.padding[0],2!==t.padding[1].length)throw new XC("ZeroPadding2D expects width padding to be a length-2 array, but received a length-"+t.padding[1].length+" array.");a=t.padding[1]}n.padding=[r,a]}return n.inputSpec=[new UR({ndim:4})],n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){var t,n;return e=zR(e),"channelsFirst"===this.dataFormat?(t=null!=e[2]&&e[2]>=0?e[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[3]&&e[3]>=0?e[3]+this.padding[1][0]+this.padding[1][1]:null,[e[0],e[1],t,n]):(t=null!=e[1]&&e[1]>=0?e[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=e[2]&&e[2]>=0?e[2]+this.padding[1][0]+this.padding[1][1]:null,[e[0],t,n,e[3]])},n.call=function(e,t){var n=this;return dx((function(){return t=LR(e),r=n.padding,a=n.dataFormat,dx((function(){if(4!==t.rank)throw new XC("temporalPadding expects input tensor to be 4-D, but received a "+t.rank+"-D tensor.");if(null==r&&(r=[[1,1],[1,1]]),2!==r.length||2!==r[0].length||2!==r[1].length)throw new XC("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==a&&(a="channelsLast"),"channelsLast"!==a&&"channelsFirst"!==a)throw new XC("Unknown data format: "+a+". Supported data formats are 'channelsLast' and 'channelsFirst.");var e;return e="channelsFirst"===a?[[0,0],[0,0],r[0],r[1]]:[[0,0],r[0],r[1],[0,0]],Jk(t,e)}));var t,r,a}))},n.getConfig=function(){var t={padding:this.padding,dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR);function m_(e,t,n,r,a,i){return dx((function(){var o;DE(a),_E(i),FE(r),null==n&&(n=[1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=cF(e,a);var s="same"===r?"same":"valid";return o="max"===i?Fk(e,t,n,s):Zx(e,t,n,s),"channelsFirst"===a&&(o=Tb(o,[0,3,1,2])),o}))}function v_(e,t,n,r,a,i){return dx((function(){var o;DE(a),_E(i),FE(r),null==n&&(n=[1,1,1]),null==r&&(r="valid"),null==a&&(a="channelsLast"),null==i&&(i="max"),e=pF(e,a);var s="same"===r?"same":"valid";return o="max"===i?_k(e,t,n,s):Qx(e,t,n,s),"channelsFirst"===a&&(o=Tb(o,[0,4,1,2,3])),o}))}d_.className="ZeroPadding2D",ax(d_);var g_=function(e){function t(t){var n;if(null==t.poolSize&&(t.poolSize=2),n=e.call(this,t)||this,"number"==typeof t.poolSize)n.poolSize=[t.poolSize];else{if(!Array.isArray(t.poolSize)||1!==t.poolSize.length||"number"!=typeof t.poolSize[0])throw new XC("poolSize for 1D convolutional layer must be a number or an Array of a single number, but received "+JSON.stringify(t.poolSize));n.poolSize=t.poolSize}if(hE(n.poolSize,"poolSize"),null==t.strides)n.strides=n.poolSize;else if("number"==typeof t.strides)n.strides=[t.strides];else{if(!Array.isArray(t.strides)||1!==t.strides.length||"number"!=typeof t.strides[0])throw new XC("strides for 1D convolutional layer must be a number or an Array of a single number, but received "+JSON.stringify(t.strides));n.strides=t.strides}return hE(n.strides,"strides"),n.padding=null==t.padding?"valid":t.padding,FE(n.padding),n.inputSpec=[new UR({ndim:3})],n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){var t=uF((e=zR(e))[1],this.poolSize[0],this.padding,this.strides[0]);return[e[0],t,e[2]]},n.call=function(e,t){var n=this;return dx((function(){n.invokeCallHook(e,t),e=qE(LR(e),2);var r=n.poolingFunction(LR(e),[n.poolSize[0],1],[n.strides[0],1],n.padding,"channelsLast");return $N(r,[2])}))},n.getConfig=function(){var t={poolSize:this.poolSize,padding:this.padding,strides:this.strides},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR),y_=function(e){function t(t){return e.call(this,t)||this}return qm(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return DE(a),FE(r),m_(e,t,n,r,a,"max")},t}(g_);y_.className="MaxPooling1D",ax(y_);var b_=function(e){function t(t){return e.call(this,t)||this}return qm(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return DE(a),FE(r),m_(e,t,n,r,a,"avg")},t}(g_);b_.className="AveragePooling1D",ax(b_);var x_=function(e){function t(t){var n;if(null==t.poolSize&&(t.poolSize=[2,2]),(n=e.call(this,t)||this).poolSize=Array.isArray(t.poolSize)?t.poolSize:[t.poolSize,t.poolSize],null==t.strides)n.strides=n.poolSize;else if(Array.isArray(t.strides)){if(2!==t.strides.length)throw new XC("If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length "+t.strides.length+".");n.strides=t.strides}else n.strides=[t.strides,t.strides];return hE(n.poolSize,"poolSize"),hE(n.strides,"strides"),n.padding=null==t.padding?"valid":t.padding,n.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,DE(n.dataFormat),FE(n.padding),n.inputSpec=[new UR({ndim:4})],n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){e=zR(e);var t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2];return t=uF(t,this.poolSize[0],this.padding,this.strides[0]),n=uF(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n]:[e[0],t,n,e[3]]},n.call=function(e,t){var n=this;return dx((function(){return n.invokeCallHook(e,t),n.poolingFunction(LR(e),n.poolSize,n.strides,n.padding,n.dataFormat)}))},n.getConfig=function(){var t={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR),w_=function(e){function t(t){return e.call(this,t)||this}return qm(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return DE(a),FE(r),m_(e,t,n,r,a,"max")},t}(x_);w_.className="MaxPooling2D",ax(w_);var k_=function(e){function t(t){return e.call(this,t)||this}return qm(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return DE(a),FE(r),m_(e,t,n,r,a,"avg")},t}(x_);k_.className="AveragePooling2D",ax(k_);var N_=function(e){function t(t){var n;if(null==t.poolSize&&(t.poolSize=[2,2,2]),(n=e.call(this,t)||this).poolSize=Array.isArray(t.poolSize)?t.poolSize:[t.poolSize,t.poolSize,t.poolSize],null==t.strides)n.strides=n.poolSize;else if(Array.isArray(t.strides)){if(3!==t.strides.length)throw new XC("If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length "+t.strides.length+".");n.strides=t.strides}else n.strides=[t.strides,t.strides,t.strides];return hE(n.poolSize,"poolSize"),hE(n.strides,"strides"),n.padding=null==t.padding?"valid":t.padding,n.dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,DE(n.dataFormat),FE(n.padding),n.inputSpec=[new UR({ndim:5})],n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){e=zR(e);var t="channelsFirst"===this.dataFormat?e[2]:e[1],n="channelsFirst"===this.dataFormat?e[3]:e[2],r="channelsFirst"===this.dataFormat?e[4]:e[3];return t=uF(t,this.poolSize[0],this.padding,this.strides[0]),n=uF(n,this.poolSize[1],this.padding,this.strides[1]),r=uF(r,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[e[0],e[1],t,n,r]:[e[0],t,n,r,e[4]]},n.call=function(e,t){var n=this;return dx((function(){return n.invokeCallHook(e,t),n.poolingFunction(LR(e),n.poolSize,n.strides,n.padding,n.dataFormat)}))},n.getConfig=function(){var t={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR),I_=function(e){function t(t){return e.call(this,t)||this}return qm(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return DE(a),FE(r),v_(e,t,n,r,a,"max")},t}(N_);I_.className="MaxPooling3D",ax(I_);var S_=function(e){function t(t){return e.call(this,t)||this}return qm(t,e),t.prototype.poolingFunction=function(e,t,n,r,a){return DE(a),FE(r),v_(e,t,n,r,a,"avg")},t}(N_);S_.className="AveragePooling3D",ax(S_);var T_=function(e){function t(t){var n;return(n=e.call(this,t)||this).inputSpec=[new UR({ndim:3})],n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return[e[0],e[2]]},n.call=function(e,t){throw new YC},t}(KR),C_=function(e){function t(t){return e.call(this,t||{})||this}return qm(t,e),t.prototype.call=function(e,t){return dx((function(){var t=LR(e);return Lk(t,1)}))},t}(T_);C_.className="GlobalAveragePooling1D",ax(C_);var E_=function(e){function t(t){return e.call(this,t||{})||this}return qm(t,e),t.prototype.call=function(e,t){return dx((function(){var t=LR(e);return mk(t,1)}))},t}(T_);E_.className="GlobalMaxPooling1D",ax(E_);var R_=function(e){function t(t){var n;return(n=e.call(this,t)||this).dataFormat=null==t.dataFormat?"channelsLast":t.dataFormat,DE(n.dataFormat),n.inputSpec=[new UR({ndim:4})],n}qm(t,e);var n=t.prototype;return n.computeOutputShape=function(e){return e=e,"channelsLast"===this.dataFormat?[e[0],e[3]]:[e[0],e[1]]},n.call=function(e,t){throw new YC},n.getConfig=function(){var t={dataFormat:this.dataFormat},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t}(KR),A_=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.call=function(e,t){var n=this;return dx((function(){var t=LR(e);return"channelsLast"===n.dataFormat?Lk(t,[1,2]):Lk(t,[2,3])}))},t}(R_);A_.className="GlobalAveragePooling2D",ax(A_);var D_=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.call=function(e,t){var n=this;return dx((function(){var t=LR(e);return"channelsLast"===n.dataFormat?mk(t,[1,2]):mk(t,[2,3])}))},t}(R_);D_.className="GlobalMaxPooling2D",ax(D_);var F_=function(e){function t(t){var n;return(n=e.call(this,t)||this).layer=t.layer,n}qm(t,e);var n=t.prototype;return n.build=function(e){this.built=!0},n.getWeights=function(){return this.layer.getWeights()},n.setWeights=function(e){this.layer.setWeights(e)},n.getConfig=function(){var t={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},n.setFastWeightInitDuringBuild=function(t){e.prototype.setFastWeightInitDuringBuild.call(this,t),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(t)},t.fromConfig=function(e,t,n){void 0===n&&(n={});var r=uA(t.layer,n);delete t.layer;var a={layer:r};return Object.assign(a,t),new e(a)},Hm(t,[{key:"trainable",get:function(){return null!=this.layer&&this.layer.trainable},set:function(e){null!=this.layer&&(this.layer.trainable=e)}},{key:"trainableWeights",get:function(){return this.layer.trainableWeights}},{key:"nonTrainableWeights",get:function(){return this.layer.nonTrainableWeights}},{key:"updates",get:function(){return this.layer._updates}},{key:"losses",get:function(){return this.layer.losses}}]),t}(KR),__=function(e){function t(t){var n;return(n=e.call(this,t)||this).supportsMasking=!0,n}qm(t,e);var n=t.prototype;return n.build=function(t){if((t=zR(t)).length<3)throw new XC("TimeDistributed layer expects an input shape >= 3D, but received input shape "+JSON.stringify(t));this.inputSpec=[{shape:t}];var n=[t[0]].concat(t.slice(2));this.layer.built||(this.layer.build(n),this.layer.built=!0),e.prototype.build.call(this,t)},n.computeOutputShape=function(e){var t=[(e=zR(e))[0]].concat(e.slice(2)),n=this.layer.computeOutputShape(t),r=e[1];return[n[0],r].concat(n.slice(1))},n.call=function(e,t){var n=this;return dx((function(){return CF((function(e,r){return[LR(n.layer.call(e,t)),[]]}),e=LR(e),[],!1,null,null,!1,!0)[1]}))},t}(F_);__.className="TimeDistributed",ax(__);var O_=function(e){function t(t){var n;n=e.call(this,t)||this;var r=t.layer.getConfig(),a={};a.className=t.layer.getClassName(),a.config=r,n.forwardLayer=uA(a),r.goBackwards=!0!==r.goBackwards;var i,o={};if(o.className=t.layer.getClassName(),o.config=r,n.backwardLayer=uA(o),n.forwardLayer.name="forward_"+n.forwardLayer.name,n.backwardLayer.name="backward_"+n.backwardLayer.name,n.mergeMode=void 0===t.mergeMode?"concat":t.mergeMode,i=n.mergeMode,cE(RE,"BidirectionalMergeMode",i),t.weights)throw new YC("weights support is not implemented for Bidirectional layer yet.");return n._stateful=t.layer.stateful,n.returnSequences=t.layer.returnSequences,n.returnState=t.layer.returnState,n.supportsMasking=!0,n._trainable=!0,n.inputSpec=t.layer.inputSpec,n.numConstants=null,n}qm(t,e);var n=t.prototype;return n.getWeights=function(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights())},n.setWeights=function(e){var t=e.length,n=Math.floor(t/2);this.forwardLayer.setWeights(e.slice(0,n)),this.backwardLayer.setWeights(e.slice(n))},n.computeOutputShape=function(e){var t,n,r,a=this.forwardLayer.computeOutputShape(e);return Array.isArray(a)&&Array.isArray(a[0])||(a=[a]),a=a,this.returnState?(r=a.slice(1),t=a[0]):t=a[0],t=t,"concat"===this.mergeMode?(t[t.length-1]*=2,n=[t]):n=null==this.mergeMode?[t,t.slice()]:[t],this.returnState?null==this.mergeMode?n.concat(r).concat(r.slice()):[t].concat(r).concat(r.slice()):eE(n)},n.apply=function(t,n){var r=null==n?null:n.initialState,a=null==n?null:n.constants;null==n&&(n={});var i=TF(t,r,a,this.numConstants);if(t=i.inputs,r=i.initialState,a=i.constants,Array.isArray(t)&&(r=t.slice(1),t=t[0]),(null==r||0===r.length)&&null==a)return e.prototype.apply.call(this,t,n);var o=[],s=[];if(null!=r){var u=r.length;if(u%2>0)throw new XC("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");n.initialState=r,o.push.apply(o,r);var l=r.map((function(e){return new UR({shape:e.shape})}));this.forwardLayer.stateSpec=l.slice(0,u/2),this.backwardLayer.stateSpec=l.slice(u/2),s.push.apply(s,l)}if(null!=a)throw new YC("Support for constants in Bidirectional layers is not implemented yet.");for(var c=o[0]instanceof GR,p=0,h=o;p<h.length;p++){if(h[p]instanceof GR!==c)throw new XC("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors")}if(c){var f=[t].concat(o),d=this.inputSpec.concat(s),m=this.inputSpec;this.inputSpec=d;var v=e.prototype.apply.call(this,f,n);return this.inputSpec=m,v}return e.prototype.apply.call(this,t,n)},n.call=function(e,t){var n=this;return dx((function(){var r,a,i,o,s=t.initialState;if(null==s)r=n.forwardLayer.call(e,t),a=n.backwardLayer.call(e,t);else{var u=s.slice(0,s.length/2),l=s.slice(s.length/2);r=n.forwardLayer.call(e,Object.assign(t,{initialState:u})),a=n.backwardLayer.call(e,Object.assign(t,{initialState:l}))}return n.returnState&&(Array.isArray(r)&&(i=r.slice(1).concat(a.slice(1))),r=r[0],a=a[0]),n.returnSequences&&(a=TN(a,1)),"concat"===n.mergeMode?o=JE([r,a]):"sum"===n.mergeMode?o=xx(r,a):"ave"===n.mergeMode?o=Nx(.5,xx(r,a)):"mul"===n.mergeMode?o=Nx(r,a):null==n.mergeMode&&(o=[r,a]),n.returnState?null==n.mergeMode?o.concat(i):[o].concat(i):o}))},n.resetStates=function(e){this.forwardLayer.resetStates(),this.backwardLayer.resetStates()},n.build=function(e){var t=this;ME(this.forwardLayer.name,(function(){t.forwardLayer.build(e)})),ME(this.backwardLayer.name,(function(){t.backwardLayer.build(e)})),this.built=!0},n.computeMask=function(e,t){var n;if(Array.isArray(t)&&(t=t[0]),n=this.returnSequences?null==this.mergeMode?[t,t]:t:null==this.mergeMode?[null,null]:null,this.returnState){var r=this.forwardLayer.states.map((function(e){return null}));return Array.isArray(n)?n.concat(r).concat(r):[n].concat(r).concat(r)}return n},n.setFastWeightInitDuringBuild=function(t){e.prototype.setFastWeightInitDuringBuild.call(this,t),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(t),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(t)},n.getConfig=function(){var t={mergeMode:this.mergeMode},n=e.prototype.getConfig.call(this);return Object.assign(t,n),t},t.fromConfig=function(e,t){var n=uA(t.layer);if(delete t.layer,null!=t.numConstants)throw new YC("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");var r=t;return r.layer=n,new e(r)},Hm(t,[{key:"trainable",get:function(){return this._trainable},set:function(e){this._trainable=e,null!=this.forwardLayer&&(this.forwardLayer.trainable=e),null!=this.backwardLayer&&(this.backwardLayer.trainable=e)}},{key:"trainableWeights",get:function(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights)}},{key:"nonTrainableWeights",get:function(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights)}}]),t}(F_);function M_(e){return new b_(e)}function L_(e){return new k_(e)}function z_(e){return new S_(e)}function P_(e){return new E_(e)}function B_(e){return new D_(e)}function W_(e){return new y_(e)}function V_(e){return new w_(e)}O_.className="Bidirectional",ax(O_);var U_={__proto__:null,inputLayer:function(e){return new YR(e)},elu:function(e){return new aF(e)},reLU:function(e){return new tF(e)},leakyReLU:function(e){return new nF(e)},prelu:function(e){return new rF(e)},softmax:function(e){return new oF(e)},thresholdedReLU:function(e){return new iF(e)},conv1d:function(e){return new kF(e)},conv2d:function(e){return new gF(e)},conv2dTranspose:function(e){return new bF(e)},conv3d:function(e){return new yF(e)},separableConv2d:function(e){return new wF(e)},cropping2D:function(e){return new NF(e)},upSampling2d:function(e){return new IF(e)},depthwiseConv2d:function(e){return new SF(e)},activation:function(e){return new qF(e)},dense:function(e){return new jF(e)},dropout:function(e){return new UF(e)},spatialDropout1d:function(e){return new GF(e)},flatten:function(e){return new HF(e)},repeatVector:function(e){return new KF(e)},reshape:function(e){return new XF(e)},permute:function(e){return new YF(e)},embedding:function(e){return new ZF(e)},add:function(e){return new $F(e)},average:function(e){return new t_(e)},concatenate:function(e){return new a_(e)},maximum:function(e){return new n_(e)},minimum:function(e){return new r_(e)},multiply:function(e){return new e_(e)},dot:function(e){return new o_(e)},batchNormalization:function(e){return new h_(e)},layerNormalization:function(e){return new f_(e)},zeroPadding2d:function(e){return new d_(e)},averagePooling1d:M_,avgPool1d:function(e){return M_(e)},avgPooling1d:function(e){return M_(e)},averagePooling2d:L_,avgPool2d:function(e){return L_(e)},avgPooling2d:function(e){return L_(e)},averagePooling3d:z_,avgPool3d:function(e){return z_(e)},avgPooling3d:function(e){return z_(e)},globalAveragePooling1d:function(e){return new C_(e)},globalAveragePooling2d:function(e){return new A_(e)},globalMaxPooling1d:P_,globalMaxPooling2d:B_,maxPooling1d:W_,maxPooling2d:V_,maxPooling3d:function(e){return new I_(e)},gru:function(e){return new _F(e)},gruCell:function(e){return new FF(e)},lstm:function(e){return new MF(e)},lstmCell:function(e){return new OF(e)},simpleRNN:function(e){return new DF(e)},simpleRNNCell:function(e){return new AF(e)},convLstm2d:function(e){return new VF(e)},convLstm2dCell:function(e){return new WF(e)},rnn:function(e){return new EF(e)},stackedRNNCells:function(e){return new LF(e)},bidirectional:function(e){return new O_(e)},timeDistributed:function(e){return new __(e)},globalMaxPool1d:P_,globalMaxPool2d:B_,maxPool1d:W_,maxPool2d:V_,Layer:KR,RNN:EF,RNNCell:RF,input:AD,gaussianNoise:function(e){return new s_(e)},gaussianDropout:function(e){return new u_(e)},alphaDropout:function(e){return new l_(e)},masking:function(e){return new JF(e)}};var G_={__proto__:null,binaryAccuracy:function(e,t){return wA(e,t)},binaryCrossentropy:function(e,t){return TA(e,t)},sparseCategoricalAccuracy:function(e,t){return CA(e,t)},categoricalAccuracy:function(e,t){return kA(e,t)},categoricalCrossentropy:function(e,t){return EA(e,t)},precision:function(e,t){return IA(e,t)},recall:function(e,t){return SA(e,t)},cosineProximity:function(e,t){return yA(e,t)},meanAbsoluteError:function(e,t){return pA(e,t)},meanAbsolutePercentageError:function(e,t){return hA(e,t)},MAPE:function(e,t){return hA(e,t)},mape:function(e,t){return hA(e,t)},meanSquaredError:function(e,t){return cA(e,t)},MSE:function(e,t){return cA(e,t)},mse:function(e,t){return cA(e,t)}},j_={__proto__:null,modelFromJSON:function(e,t){return ID.apply(this,arguments)}};var H_={__proto__:null,l1l2:function(e){return new JD(e)},l1:function(e){return XD(t=e),new JD({l1:null!=t?t.l1:null,l2:0});var t},l2:function(e){return XD(t=e),new JD({l2:null!=t?t.l2:null,l1:0});var t}},q_=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).model=null,t}return qm(t,e),t.prototype.setModel=function(e){if(!(e instanceof kD))throw new Error("model must be a LayersModel, not some other Container");this.model=e},t}(eA);function K_(e,t){return e<t}function X_(e,t){return e>t}var Y_=function(e){function t(t){var n;if(n=e.call(this)||this,null==t&&(t={}),t.restoreBestWeights)throw new YC("restoreBestWeights = True is not implemented in EarlyStopping yet.");return n.monitor=t.monitor||"val_loss",n.minDelta=Math.abs(t.minDelta||0),n.patience=t.patience||0,n.verbose=t.verbose||0,n.mode=t.mode||"auto",n.baseline=t.baseline,-1===["auto","min","max"].indexOf(n.mode)&&(console.warn("EarlyStopping mode '"+n.mode+"' is invalid. Falling back to mode 'auto'."),n.mode="auto"),"min"===n.mode?n.monitorFunc=K_:"max"===n.mode||-1!==n.monitor.indexOf("acc")?n.monitorFunc=X_:n.monitorFunc=K_,n.monitorFunc===K_&&(n.minDelta*=-1),n}qm(t,e);var n=t.prototype;return n.onTrainBegin=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===K_?1/0:-1/0;case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.onEpochEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ZR(n);case 2:if(null!=(r=this.getMonitorValue(n))){e.next=5;break}return e.abrupt("return");case 5:this.monitorFunc(r-this.minDelta,this.best)?(this.best=r,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=t,this.model.stopTraining=!0));case 6:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.onTrainEnd=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.stoppedEpoch>0&&this.verbose&&console.log("Epoch "+this.stoppedEpoch+": early stopping.");case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getMonitorValue=function(e){null==e&&(e={});var t=e[this.monitor];return null==t&&console.warn("Metric for EarlyStopping "+this.monitor+" is not available. Available metrics are: "+Object.keys(e)),t},t}(q_);var J_,Z_,Q_={earlyStopping:function(e){return new Y_(e)}};!function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF"}(J_||(J_={})),function(e){!function(e){e[e.LEGACY=0]="LEGACY",e[e.V1=1]="V1",e[e.V2=2]="V2"}(e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))}(Z_||(Z_={}));var $_={};function eO(e){return $_[e]}function tO(e,t,n,r,a){var i=t.inputParams[e];if(i&&void 0!==i.inputIndexStart){var o=i.inputIndexStart,s=0===i.inputIndexEnd?void 0:void 0===i.inputIndexEnd?o+1:i.inputIndexEnd;if("tensor"===i.type)return nO(t.inputNames[i.inputIndexStart],n,r,a);if("tensors"===i.type)return t.inputNames.slice(o,s).map((function(e){return nO(e,n,r,a)}));var u=nO(t.inputNames.slice(o)[0],n,r,a),l=u.dataSync();return"number"===i.type?l[0]:zv(u.shape,l)}var c=t.attrParams[e];return c&&c.value}function nO(e,t,n,r){var a=iO(e),i=a[0],o=a[1];if(null!=r){var s=r.getHashTableHandleByName(i);if(null!=s)return s}var u=n.currentContextIds.find((function(e){return!!t[aO(i,e)]}));return void 0!==u?t[aO(i,u)][o]:void 0}function rO(e,t){var n=iO(e),r=n[0],a=n[1];return[aO(r,t&&t.currentContextId),a]}function aO(e,t){return t?e+"-"+t:e}function iO(e){var t=e.split(":");return 1===t.length?[e,0]:[t[0],Number(t[t.length-1])]}function oO(e,t,n){var r=tO("pad",e,t,n);if("explicit"===r){r=tO("explicitPaddings",e,t,n);for(var a=[[0,0],[0,0],[0,0],[0,0]],i=0;i<4;i++)a[i][0]=r[2*i],a[i][1]=r[2*i+1];return a}return r}function sO(e){return e.kept?e:ab(e)}var uO={__proto__:null,json:[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},lO={__proto__:null,json:[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},cO={__proto__:null,json:[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]}]},pO={__proto__:null,json:[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number"}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}]},hO={__proto__:null,json:[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}]},fO={__proto__:null,json:[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},dO={__proto__:null,json:[{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}]},mO={__proto__:null,json:[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}]},vO={__proto__:null,json:[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]}]},gO={__proto__:null,json:[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]}]},yO={__proto__:null,json:[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},bO={__proto__:null,json:[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]},xO={__proto__:null,json:[{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}]},wO={__proto__:null,json:[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}]},kO={__proto__:null,json:[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}]},NO={__proto__:null,json:[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}]},IO={__proto__:null,json:[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]}]},SO=function(){function e(){var e,t=[uO,lO,cO,pO,hO,fO,dO,yO,gO,mO,bO,xO,wO,kO,NO,IO,vO],n=(e=[]).concat.apply(e,t.map((function(e){return e.json})));this.opMappers=n.reduce((function(e,t){return e[t.tfOpName]=t,e}),{})}Hm(e,null,[{key:"Instance",get:function(){return this._instance||(this._instance=new this)}}]);var t=e.prototype;return t.transformGraph=function(e,t){var n=this;void 0===t&&(t={});var r=e.node,a=[],i=[],o=[],s=r.reduce((function(e,t){return e[t.name]=n.mapNode(t),t.op.startsWith("Placeholder")?a.push(e[t.name]):"Const"===t.op?i.push(e[t.name]):null!=t.input&&0!==t.input.length||o.push(e[t.name]),e}),{}),u=[],l=[],c={},p={};null!=t&&(c=this.mapSignatureEntries(t.inputs),p=this.mapSignatureEntries(t.outputs));var h=Object.keys(s);h.forEach((function(e){var t=s[e];t.inputNames.forEach((function(e){var n=rO(e)[0];t.inputs.push(s[n]),s[n].children.push(t)}))})),0===Object.keys(p).length?h.forEach((function(e){var t=s[e];0===t.children.length&&l.push(t)})):Object.keys(p).forEach((function(e){var t=rO(e)[0],n=s[t];null!=n&&(n.signatureKey=p[e],l.push(n))})),Object.keys(c).length>0?Object.keys(c).forEach((function(e){var t=rO(e)[0],n=s[t];n&&(n.signatureKey=c[e],u.push(n))})):u=a;var f={};null!=e.library&&null!=e.library.function&&(f=e.library.function.reduce((function(e,t){return e[t.signature.name]=n.mapFunction(t),e}),{}));var d={nodes:s,inputs:u,outputs:l,weights:i,placeholders:a,signature:t,functions:f};return o.length>0&&(d.initNodes=o),d},t.mapSignatureEntries=function(e){return Object.keys(e||{}).reduce((function(t,n){return t[e[n].name]=n,t}),{})},t.mapNode=function(e){var t=eO(e.op)||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});var n={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map((function(e){return e.startsWith("^")?e.substr(1):e})),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr};return null!=t.inputs&&(n.inputParams=t.inputs.reduce((function(e,t){return e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e}),{})),null!=t.attrs&&(n.attrParams=t.attrs.reduce((function(t,n){var r=n.type,a=void 0;switch(n.type){case"string":void 0===(a=CO(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=CO(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":void 0===(a=zO(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=zO(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":void 0===(a=RO(e.attr,n.tfName,n.defaultValue||0))&&n.tfDeprecatedName&&(a=RO(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":void 0===(a=LO(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=LO(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":void 0===(a=EO(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=EO(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":void 0===(a=BO(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=BO(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":void 0===(a=MO(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=MO(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":void 0===(a=PO(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=PO(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":void 0===(a=FO(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=FO(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":void 0===(a=_O(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=_O(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":void 0===(a=DO(e.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(a=DO(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error("Unsupported param type: "+n.type+" for op: "+e.op)}return t[n.name]={value:a,type:r},t}),{})),n},t.mapFunction=function(e){var t=this,n=e.nodeDef,r=[],a={};null!=n&&(a=n.reduce((function(e,n){return e[n.name]=t.mapNode(n),"Const"===n.op&&r.push(e[n.name]),e}),{}));var i=[],o=[];e.signature.inputArg.forEach((function(e){var t=rO(e.name)[0],n={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:AO(e.type),type:"dtype"}},children:[]};n.signatureKey=e.name,i.push(n),a[t]=n})),Object.keys(a).forEach((function(e){var t=a[e];t.inputNames.forEach((function(e){var n=rO(e)[0];t.inputs.push(a[n]),a[n].children.push(t)}))}));var s=e.ret;e.signature.outputArg.forEach((function(e){var t=rO(s[e.name]),n=t[0],r=t[1],i=a[n];null!=i&&(i.defaultOutput=r,o.push(i))}));var u=this.mapArgsToSignature(e);return{nodes:a,inputs:i,outputs:o,weights:r,placeholders:[],signature:u}},t.mapArgsToSignature=function(e){var t=this;return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce((function(e,n){return e[n.name]=t.mapArgToTensorInfo(n),e}),{}),outputs:e.signature.outputArg.reduce((function(n,r){return n[r.name]=t.mapArgToTensorInfo(r,e.ret),n}),{})}},t.mapArgToTensorInfo=function(e,t){var n=e.name;return null!=t&&(n=t[n]),{name:n,dtype:e.type}},e}();function TO(e,t){var n=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){var t=Xv().global;if(void 0!==t.atob)return t.atob(e);if("undefined"!=typeof Buffer)return new Buffer(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?n:n.toLowerCase()}function CO(e,t,n,r){void 0===r&&(r=!1);var a=e[t];return null!=a?TO(a.s,r):n}function EO(e,t,n){var r=e[t];return r?r.b:n}function RO(e,t,n){var r=e[t]||{},a=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof a?a:parseInt(a,10)}function AO(e){switch("string"==typeof e&&(e=J_[e]),e){case J_.DT_FLOAT:return"float32";case J_.DT_INT32:case J_.DT_INT64:case J_.DT_INT8:case J_.DT_UINT8:return"int32";case J_.DT_BOOL:return"bool";case J_.DT_DOUBLE:return"float32";case J_.DT_STRING:return"string";default:return null}}function DO(e,t,n){var r=e[t];return r&&r.func?r.func.name:n}function FO(e,t,n){var r=e[t];return r&&r.type?AO(r.type):n}function _O(e,t,n){var r=e[t];return r&&r.list&&r.list.type?r.list.type.map((function(e){return AO(e)})):n}function OO(e){if(!e.unknownRank)return null!=e.dim?e.dim.map((function(e){return"number"==typeof e.size?e.size:parseInt(e.size,10)})):[]}function MO(e,t,n){var r=e[t];return r&&r.shape?OO(r.shape):n}function LO(e,t,n){var r=e[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map((function(e){return"number"==typeof e?e:parseInt(e,10)})):n}function zO(e,t,n,r){void 0===r&&(r=!1);var a=e[t];return a&&a.list&&a.list.s?a.list.s.map((function(e){return TO(e,r)})):n}function PO(e,t,n){var r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map((function(e){return OO(e)})):n}function BO(e,t,n){var r=e[t];return r&&r.list&&r.list.b?r.list.b:n}var WO=function(){function e(e,t,n){var r=this;this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map((function(e){return r.getInput(e)})),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce((function(e,t){return e[t]=r.getAttr(t),e}),{}))}var t=e.prototype;return t.getInput=function(e){return nO(e,this.tensorMap,this.context)},t.getAttr=function(e,t){var n=this.node.rawAttrs[e];if(null!=n.tensor)return nO(e,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return RO(this.node.rawAttrs,e,t);if(null!=n.s)return CO(this.node.rawAttrs,e,t);if(null!=n.b)return EO(this.node.rawAttrs,e,t);if(null!=n.shape)return MO(this.node.rawAttrs,e,t);if(null!=n.type)return FO(this.node.rawAttrs,e,t);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return LO(this.node.rawAttrs,e,t);if(null!=n.list.s)return zO(this.node.rawAttrs,e,t);if(null!=n.list.shape)return PO(this.node.rawAttrs,e,t);if(null!=n.list.b)return BO(this.node.rawAttrs,e,t);if(null!=n.list.type)return _O(this.node.rawAttrs,e,t)}return t},e}();function VO(e,t,n){void 0===n&&(n=""),lv(function(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(-1!==e[n]&&-1!==t[n]&&e[n]!==t[n])return!1;return!0}(e,t),(function(){return n+" Shapes "+e+" and "+t+" must match"}))}var UO=function(){function e(e,t,n,r,a,i,o){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=i,this.clearAfterRead=o,this.tensors=[],this.closed_=!1,this.idTensor=_N(0),vx(this.idTensor)}var t=e.prototype;return t.clearAndClose=function(e){this.tensors.forEach((function(t){null!=e&&e.has(t.tensor.id)||t.tensor.dispose()})),this.tensors=[],this.closed_=!0,this.idTensor.dispose()},t.size=function(){return this.tensors.length},t.read=function(e){if(this.closed_)throw new Error("TensorArray "+this.name+" has already been closed.");if(e<0||e>=this.size())throw new Error("Tried to read from index "+e+", but array size is: "+this.size());var t=this.tensors[e];if(t.cleared)throw new Error("TensorArray "+this.name+": Could not read index "+e+" twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).");return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor},t.readMany=function(e){var t=this;return e.map((function(e){return t.read(e)}))},t.write=function(e,t){if(this.closed_)throw new Error("TensorArray "+this.name+" has already been closed.");if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error("Tried to write to index "+e+", but array is not resizeable and size is: "+this.maxSize);var n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+e+",\n          because the value dtype is "+t.dtype+", but TensorArray dtype is "+this.dtype+".");if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=t.shape),VO(this.elementShape,t.shape,"TensorArray "+this.name+": Could not write to TensorArray index "+e+"."),n.read)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+e+", because it has already been read.");if(n.written)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+e+", because it has already been written.");n.tensor=t,vx(t),n.written=!0,this.tensors[e]=n},t.writeMany=function(e,t){var n=this;if(e.length!==t.length)throw new Error("TensorArray "+this.name+": could not write multiple tensors,because the index size: "+e.length+" is not the same as tensors size: "+t.length+".");e.forEach((function(e,r){return n.write(e,t[r])}))},t.gather=function(e,t){if(t&&t!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but gather requested dtype "+t);if(e)e=e.slice(0,this.size());else{e=[];for(var n=0;n<this.size();n++)e.push(n)}if(0===e.length)return ly([],[0].concat(this.elementShape));var r=this.readMany(e);return VO(this.elementShape,r[0].shape,"TensorArray shape mismatch: "),eI(r,0)},t.concat=function(e){if(e&&e!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but concat requested dtype "+e);if(0===this.size())return ly([],[0].concat(this.elementShape));for(var t=[],n=0;n<this.size();n++)t.push(n);var r=this.readMany(t);return VO(this.elementShape,r[0].shape,"TensorArray shape mismatch: tensor array shape ("+this.elementShape+") vs first tensor shape ("+r[0].shape+")"),$x(r,0)},t.scatter=function(e,t){if(t.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+t.dtype);if(e.length!==t.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: "+e.length+" vs. "+t.shape[0]);var n=Math.max.apply(Math,e);if(!this.dynamicSize&&n>=this.maxSize)throw new Error("Max index must be < array size ("+n+"  vs. "+this.maxSize+")");this.writeMany(e,cI(t,0))},t.split=function(e,t){var n=this;if(t.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+t.dtype);var r=0,a=e.map((function(e){return r+=e}));if(r!==t.shape[0])throw new Error("Expected sum of lengths to be equal to\n          tensor.shape[0], but sum of lengths is\n        "+r+", and tensor's shape is: "+t.shape);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error("TensorArray's size is not equal to the size of lengths ("+this.maxSize+" vs. "+e.length+"), and the TensorArray is not marked as dynamically resizeable");var i=0===r?0:t.size/r,o=[];dx((function(){t=Jx(t,[1,r,i]);for(var s=0;s<e.length;++s){var u=[0,0===s?0:a[s-1],0],l=[1,e[s],i];o[s]=Jx(tw(t,u,l),n.elementShape)}return o}));for(var s=[],u=0;u<e.length;u++)s[u]=u;this.writeMany(s,o)},Hm(e,[{key:"id",get:function(){return this.idTensor.id}},{key:"closed",get:function(){return this.closed_}}]),e}(),GO=function(){function e(e,t,n,r){void 0===r&&(r=-1),this.tensors=e,this.elementShape=t,this.elementDtype=n,null!=e&&e.forEach((function(e){if(n!==e.dtype)throw new Error("Invalid data types; op elements "+n+", but list elements "+e.dtype);VO(t,e.shape,"TensorList shape mismatch: "),vx(e)})),this.idTensor=_N(0),this.maxNumElements=r,vx(this.idTensor)}var t=e.prototype;return t.copy=function(){return new e([].concat(this.tensors),this.elementShape,this.elementDtype)},t.clearAndClose=function(e){this.tensors.forEach((function(t){null!=e&&e.has(t.id)||t.dispose()})),this.tensors.length=0,this.idTensor.dispose()},t.size=function(){return this.tensors.length},t.stack=function(e,t,n){var r=this;if(void 0===n&&(n=-1),t!==this.elementDtype)throw new Error("Invalid data types; op elements "+t+", but list elements "+this.elementDtype);if(-1!==n&&this.tensors.length!==n)throw new Error("Operation expected a list with "+n+" elements but got a list with "+this.tensors.length+" elements.");return VO(e,this.elementShape,"TensorList shape mismatch: "),dx((function(){var t=r.tensors.map((function(t){return Jx(t,e)}));return eI(t,0)}))},t.popBack=function(e,t){if(t!==this.elementDtype)throw new Error("Invalid data types; op elements "+t+", but list elements "+this.elementDtype);if(0===this.size())throw new Error("Trying to pop from an empty list.");var n=this.tensors.pop();return VO(n.shape,e,"TensorList shape mismatch: "),Jx(n,e)},t.pushBack=function(e){if(e.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements "+e.dtype+", but list elements "+this.elementDtype);if(VO(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");vx(e),this.tensors.push(e)},t.resize=function(e){if(e<0)throw new Error("TensorListResize expects size to be non-negative. Got: "+e);if(-1!==this.maxNumElements&&e>this.maxNumElements)throw new Error("TensorListResize input size "+e+" is greater maxNumElement "+this.maxNumElements+".");this.tensors.length=e},t.getItem=function(e,t,n){if(n!==this.elementDtype)throw new Error("Invalid data types; op elements "+n+", but list elements "+this.elementDtype);if(e<0||e>this.tensors.length)throw new Error("Trying to access element "+e+" in a list with "+this.tensors.length+" elements.");if(null==this.tensors[e])throw new Error("element at index "+e+" is null.");return VO(this.tensors[e].shape,t,"TensorList shape mismatch: "),this.tensors[e]},t.setItem=function(e,t){if(t.dtype!==this.elementDtype)throw new Error("Invalid data types; op elements "+t.dtype+", but list elements "+this.elementDtype);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw new Error("Trying to set element "+e+" in a list with max "+this.maxNumElements+" elements.");VO(this.elementShape,t.shape,"TensorList shape mismatch: "),vx(t),this.tensors[e]=t},t.gather=function(e,t,n){var r=this;if(t!==this.elementDtype)throw new Error("Invalid data types; op elements "+t+", but list elements "+this.elementDtype);return VO(this.elementShape,n,"TensorList shape mismatch: "),0===(e=e.slice(0,this.size())).length?ly([],[0].concat(this.elementShape)):dx((function(){var t=e.map((function(e){return Jx(r.tensors[e],n)}));return eI(t,0)}))},t.concat=function(e,t){var n=this;if(e&&e!==this.elementDtype)throw new Error("TensorList dtype is "+this.elementDtype+" but concat requested dtype "+e);return VO(this.elementShape,t,"TensorList shape mismatch: "),0===this.size()?ly([],[0].concat(this.elementShape)):dx((function(){var e=n.tensors.map((function(e){return Jx(e,t)}));return $x(e,0)}))},Hm(e,[{key:"id",get:function(){return this.idTensor.id}}]),e}();function jO(e,t,n){var r=e.dtype;if(e.shape.length<1)throw new Error("Tensor must be at least a vector, but saw shape: "+e.shape);if(e.dtype!==n)throw new Error("Invalid data types; op elements "+e.dtype+", but list elements "+n);VO(e.shape.slice(1),t,"TensorList shape mismatch: ");var a=cI(e);return new GO(a,t,r)}function HO(e,t,n){return new GO([],e,t,n)}function qO(e,t,n,r){if(t.length!==e.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: "+t.length+" vs. "+e.shape[0]);var a=Math.max.apply(Math,t);if(null!=r&&-1!==r&&a>=r)throw new Error("Max index must be < array size ("+a+"  vs. "+r+")");var i=new GO([],n,e.dtype,r),o=cI(e,0);return t.forEach((function(e,t){i.setItem(e,o[t])})),i}function KO(e,t,n){var r=0,a=t.map((function(e){return r+=e}));if(r!==e.shape[0])throw new Error("Expected sum of lengths to be equal to\n          tensor.shape[0], but sum of lengths is\n        "+r+", and tensor's shape is: "+e.shape);for(var i=0===r?0:e.size/r,o=dx((function(){var o=[];e=Jx(e,[1,r,i]);for(var s=0;s<t.length;++s){var u=[0,0===s?0:a[s-1],0],l=[1,t[s],i];o[s]=Jx(tw(e,u,l),n)}return e.dispose(),o})),s=new GO([],n,e.dtype,t.length),u=0;u<o.length;u++)s.setItem(u,o[u]);return s}var XO=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h,f,d,m,v,g,y,b,x,w,k,N,I,S,T,C,E,R,A,D,F,_,O,M,L,z,P,B,W,V,U,G,j,H,q,K,X,Y,J,Z,Q,$,ee,te,ne,re,ae,ie,oe,se,ue,le,ce,pe,he,fe,de,me,ve,ge,ye,be,xe,we,ke,Ne,Ie,Se,Te,Ce,Ee,Re,Ae,De,Fe,_e,Oe,Me,Le,ze,Pe,Be,We,Ve,Ue,Ge,je,He;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.op,e.next="If"===e.t0||"StatelessIf"===e.t0?3:"While"===e.t0||"StatelessWhile"===e.t0?15:"LoopCond"===e.t0?19:"Switch"===e.t0?21:"Merge"===e.t0?32:"Enter"===e.t0?37:"Exit"===e.t0?41:"NextIteration"===e.t0?44:"TensorArrayV3"===e.t0?47:"TensorArrayWriteV3"===e.t0?57:"TensorArrayReadV3"===e.t0?63:"TensorArrayGatherV3"===e.t0?67:"TensorArrayScatterV3"===e.t0?72:"TensorArrayConcatV3"===e.t0?78:"TensorArraySplitV3"===e.t0?82:"TensorArraySizeV3"===e.t0?88:"TensorArrayCloseV3"===e.t0?91:"TensorListSetItem"===e.t0?95:"TensorListGetItem"===e.t0?101:"TensorListScatterV2"===e.t0||"TensorListScatter"===e.t0?107:"TensorListReserve"===e.t0||"EmptyTensorList"===e.t0?114:"TensorListGather"===e.t0?121:"TensorListStack"===e.t0?127:"TensorListFromTensor"===e.t0?133:"TensorListConcat"===e.t0?139:"TensorListPushBack"===e.t0?144:"TensorListPopBack"===e.t0?149:"TensorListSplit"===e.t0?154:160;break;case 3:return a=tO("thenBranch",t,n,r),i=tO("elseBranch",t,n,r),o=tO("cond",t,n,r),s=tO("args",t,n,r),e.next=9,o.data();case 9:if(!e.sent[0]){e.next=14;break}return e.abrupt("return",r.functionMap[a].executeFunctionAsync(s,r.tensorArrayMap,r.tensorListMap));case 14:return e.abrupt("return",r.functionMap[i].executeFunctionAsync(s,r.tensorArrayMap,r.tensorListMap));case 15:return e.delegateYield(regeneratorRuntime.mark((function e(){var a,i,o,s,u,l,c,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=tO("body",t,n,r),i=tO("cond",t,n,r),o=tO("args",t,n,r),e.next=5,r.functionMap[i].executeFunctionAsync(o,r.tensorArrayMap,r.tensorListMap);case 5:return s=e.sent,u=o.map((function(e){return e.id})),e.next=9,s[0].data();case 9:l=e.sent,s.forEach((function(e){e.kept||-1!==u.indexOf(e.id)||e.dispose()})),c=o,p=regeneratorRuntime.mark((function e(){var t,n,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c,e.next=3,r.functionMap[a].executeFunctionAsync(c,r.tensorArrayMap,r.tensorListMap);case 3:return c=e.sent,n=c.map((function(e){return e.id})),t.forEach((function(e){e.kept||-1!==u.indexOf(e.id)||-1!==n.indexOf(e.id)||e.dispose()})),e.next=8,r.functionMap[i].executeFunctionAsync(c,r.tensorArrayMap,r.tensorListMap);case 8:return o=e.sent,e.next=11,o[0].data();case 11:l=e.sent,o.forEach((function(e){e.kept||-1!==u.indexOf(e.id)||-1!==n.indexOf(e.id)||e.dispose()}));case 13:case"end":return e.stop()}}),e)}));case 13:if(!l[0]){e.next=17;break}return e.delegateYield(p(),"t0",15);case 15:e.next=13;break;case 17:return e.abrupt("return",{v:c});case 18:case"end":return e.stop()}}),e)}))(),"t1",16);case 16:if("object"!=typeof(u=e.t1)){e.next=19;break}return e.abrupt("return",u.v);case 19:return l=tO("pred",t,n,r),e.abrupt("return",[sO(l)]);case 21:return c=tO("pred",t,n,r),(p=tO("data",t,n,r)).kept||(p=sO(p)),e.next=26,c.data();case 26:if(!e.sent[0]){e.next=30;break}e.t2=[void 0,p],e.next=31;break;case 30:e.t2=[p,void 0];case 31:return e.abrupt("return",e.t2);case 32:if(!(h=t.inputNames.find((function(e){return void 0!==nO(e,n,r)})))){e.next=36;break}return f=nO(h,n,r),e.abrupt("return",[sO(f)]);case 36:return e.abrupt("return",void 0);case 37:return d=tO("frameName",t,n,r),m=tO("tensor",t,n,r),r.enterFrame(d),e.abrupt("return",[sO(m)]);case 41:return v=tO("tensor",t,n,r),r.exitFrame(),e.abrupt("return",[sO(v)]);case 44:return g=tO("tensor",t,n,r),r.nextIteration(),e.abrupt("return",[sO(g)]);case 47:return y=tO("size",t,n,r),b=tO("dtype",t,n,r),x=tO("elementShape",t,n,r),w=tO("dynamicSize",t,n,r),k=tO("clearAfterRead",t,n,r),N=tO("identicalElementShapes",t,n,r),I=tO("name",t,n,r),S=new UO(I,b,y,x,N,w,k),r.addTensorArray(S),e.abrupt("return",[S.idTensor,_N(1)]);case 57:return T=tO("tensorArrayId",t,n,r),C=tO("index",t,n,r),E=tO("tensor",t,n,r),(R=r.getTensorArray(T.id)).write(C,E),e.abrupt("return",[R.idTensor]);case 63:return A=tO("tensorArrayId",t,n,r),D=tO("index",t,n,r),F=r.getTensorArray(A.id),e.abrupt("return",[F.read(D)]);case 67:return _=tO("tensorArrayId",t,n,r),O=tO("indices",t,n,r),M=tO("dtype",t,n,r),L=r.getTensorArray(_.id),e.abrupt("return",[L.gather(O,M)]);case 72:return z=tO("tensorArrayId",t,n,r),P=tO("indices",t,n,r),B=tO("tensor",t,n,r),(W=r.getTensorArray(z.id)).scatter(P,B),e.abrupt("return",[W.idTensor]);case 78:return V=tO("tensorArrayId",t,n,r),U=r.getTensorArray(V.id),G=tO("dtype",t,n,r),e.abrupt("return",[U.concat(G)]);case 82:return j=tO("tensorArrayId",t,n,r),H=tO("tensor",t,n,r),q=tO("lengths",t,n,r),(K=r.getTensorArray(j.id)).split(q,H),e.abrupt("return",[K.idTensor]);case 88:return X=tO("tensorArrayId",t,n,r),Y=r.getTensorArray(X.id),e.abrupt("return",[_N(Y.size(),"int32")]);case 91:return J=tO("tensorArrayId",t,n,r),(Z=r.getTensorArray(J.id)).clearAndClose(),e.abrupt("return",[Z.idTensor]);case 95:return Q=tO("tensorListId",t,n,r),$=tO("index",t,n,r),ee=tO("tensor",t,n,r),(te=r.getTensorList(Q.id)).setItem($,ee),e.abrupt("return",[te.idTensor]);case 101:return ne=tO("tensorListId",t,n,r),re=tO("index",t,n,r),ae=tO("elementShape",t,n,r),ie=tO("elementDType",t,n,r),oe=r.getTensorList(ne.id),e.abrupt("return",[oe.getItem(re,ae,ie)]);case 107:return se=tO("indices",t,n,r),ue=tO("tensor",t,n,r),le=tO("elementShape",t,n,r),ce=tO("numElements",t,n,r),pe=qO(ue,se,le,ce),r.addTensorList(pe),e.abrupt("return",[pe.idTensor]);case 114:return he=tO("elementShape",t,n,r),fe=tO("elementDType",t,n,r),de="TensorListReserve"===t.op?"numElements":"maxNumElements",me=tO(de,t,n,r),ve=HO(he,fe,me),r.addTensorList(ve),e.abrupt("return",[ve.idTensor]);case 121:return ge=tO("tensorListId",t,n,r),ye=tO("indices",t,n,r),be=tO("elementShape",t,n,r),xe=tO("elementDType",t,n,r),we=r.getTensorList(ge.id),e.abrupt("return",[we.gather(ye,xe,be)]);case 127:return ke=tO("tensorListId",t,n,r),Ne=tO("elementShape",t,n,r),Ie=tO("elementDType",t,n,r),Se=tO("numElements",t,n,r),Te=r.getTensorList(ke.id),e.abrupt("return",[Te.stack(Ne,Ie,Se)]);case 133:return Ce=tO("tensor",t,n,r),Ee=tO("elementShape",t,n,r),Re=tO("elementDType",t,n,r),Ae=jO(Ce,Ee,Re),r.addTensorList(Ae),e.abrupt("return",[Ae.idTensor]);case 139:return De=tO("tensorListId",t,n,r),Fe=r.getTensorList(De.id),_e=tO("dtype",t,n,r),Oe=tO("elementShape",t,n,r),e.abrupt("return",[Fe.concat(_e,Oe)]);case 144:return Me=tO("tensorListId",t,n,r),Le=tO("tensor",t,n,r),(ze=r.getTensorList(Me.id)).pushBack(Le),e.abrupt("return",[ze.idTensor]);case 149:return Pe=tO("tensorListId",t,n,r),Be=tO("elementShape",t,n,r),We=tO("elementDType",t,n,r),Ve=r.getTensorList(Pe.id),e.abrupt("return",[Ve.popBack(Be,We)]);case 154:return Ue=tO("tensor",t,n,r),Ge=tO("elementShape",t,n,r),je=tO("lengths",t,n,r),He=KO(Ue,je,Ge),r.addTensorList(He),e.abrupt("return",[He.idTensor]);case 160:throw TypeError("Node type "+t.op+" is not implemented");case 161:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}();function YO(e,t,n){var r=tO("fusedOps",e,t,n),a=r[0],i=r[1],o="biasadd"===a,s="prelu"===i,u="fusedbatchnorm"===a,l=tO("numArgs",e,t,n);if(o){if(s&&2!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!s&&1!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(u)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported.");var c=tO("strides",e,t,n),p=oO(e,t,n),h=tO("dataFormat",e,t,n).toUpperCase(),f=tO("dilations",e,t,n),d=tO("args",e,t,n);return{stride:c,pad:p,dataFormat:h,dilations:f,biasArg:d[0],preluArg:d[1],activationFunc:i,leakyreluAlpha:tO("leakyreluAlpha",e,t,n)}}function JO(e,t,n){return{boxes:tO("boxes",e,t,n),scores:tO("scores",e,t,n),maxOutputSize:tO("maxOutputSize",e,t,n),iouThreshold:tO("iouThreshold",e,t,n),scoreThreshold:tO("scoreThreshold",e,t,n),softNmsSigma:tO("softNmsSigma",e,t,n)}}var ZO=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n,r){var a,i,o,s,u,l,c,p,h,f,d,m,v,g,y,b,x,w,k,N,I,S,T,C;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.op,e.next="NonMaxSuppressionV5"===e.t0?3:"NonMaxSuppressionV4"===e.t0?8:"NonMaxSuppressionV3"===e.t0||"NonMaxSuppressionV2"===e.t0?14:"Where"===e.t0?19:"ListDiff"===e.t0?26:27;break;case 3:return a=JO(t,n,r),i=a.boxes,o=a.scores,s=a.maxOutputSize,u=a.iouThreshold,l=a.scoreThreshold,c=a.softNmsSigma,e.next=6,GS.nonMaxSuppressionWithScoreAsync(i,o,s,u,l,c);case 6:return p=e.sent,e.abrupt("return",[p.selectedIndices,p.selectedScores]);case 8:return h=JO(t,n,r),f=h.boxes,d=h.scores,m=h.maxOutputSize,v=h.iouThreshold,g=h.scoreThreshold,y=tO("padToMaxOutputSize",t,n,r),e.next=12,GS.nonMaxSuppressionPaddedAsync(f,d,m,v,g,y);case 12:return b=e.sent,e.abrupt("return",[b.selectedIndices,b.validOutputs]);case 14:return x=JO(t,n,r),w=x.boxes,k=x.scores,N=x.maxOutputSize,I=x.iouThreshold,S=x.scoreThreshold,e.next=17,GS.nonMaxSuppressionAsync(w,k,N,I,S);case 17:return e.t1=e.sent,e.abrupt("return",[e.t1]);case 19:return T=rb(tO("condition",t,n,r),"bool"),e.next=22,dI(T);case 22:return e.t2=e.sent,C=[e.t2],T.dispose(),e.abrupt("return",C);case 26:return e.abrupt("return",zN(tO("x",t,n,r),tO("y",t,n,r)));case 27:throw TypeError("Node type "+t.op+" is not implemented");case 28:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),QO=function(){function e(e,t){this.keyDType=e,this.valueDType=t,this.handle=_N(0),this.tensorMap=new Map,vx(this.handle)}var t=e.prototype;return t.clearAndClose=function(){this.tensorMap.forEach((function(e){return e.dispose()})),this.tensorMap.clear(),this.handle.dispose()},t.size=function(){return this.tensorMap.size},t.import=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r,a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.checkKeyAndValueTensor(t,n),e.next=3,t.data();case 3:return r=e.sent,this.tensorMap.forEach((function(e){return e.dispose()})),this.tensorMap.clear(),e.abrupt("return",dx((function(){var e=cI(n),t=r.length,i=e.length;lv(t===i,(function(){return"The number of elements doesn't match, keys has "+t+" elements, the values has "+i+" elements."}));for(var o=0;o<t;o++){var s=r[o],u=e[o];vx(u),a.tensorMap.set(s,u)}return a.handle})));case 7:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.find=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r,a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.checkKeyAndValueTensor(t,n),e.next=3,t.data();case 3:return r=e.sent,e.abrupt("return",dx((function(){for(var e=[],t=0;t<r.length;t++){var i=r[t],o=a.findWithDefault(i,n);e.push(o)}return eI(e)})));case 5:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.findWithDefault=function(e,t){var n=this.tensorMap.get(e);return null!=n?n:t},t.checkKeyAndValueTensor=function(e,t){if(e.dtype!==this.keyDType)throw new Error("Expect key dtype "+this.keyDType+", but got "+e.dtype);if(t.dtype!==this.valueDType)throw new Error("Expect value dtype "+this.valueDType+", but got "+t.dtype)},Hm(e,[{key:"id",get:function(){return this.handle.id}}]),e}(),$O=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n,r,a){var i,o,s,u,l,c,p,h,f,d,m;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.op,e.next="HashTable"===e.t0||"HashTableV2"===e.t0?3:"LookupTableImport"===e.t0||"LookupTableImportV2"===e.t0?8:"LookupTableFind"===e.t0||"LookupTableFindV2"===e.t0?16:24;break;case 3:return i=tO("keyDType",t,n,r),o=tO("valueDType",t,n,r),s=new QO(i,o),a.addHashTable(t.name,s),e.abrupt("return",[s.handle]);case 8:return u=tO("tableHandle",t,n,r,a),l=tO("keys",t,n,r),c=tO("values",t,n,r),p=a.getHashTableById(u.id),e.next=14,p.import(l,c);case 14:return e.t1=e.sent,e.abrupt("return",[e.t1]);case 16:return h=tO("tableHandle",t,n,r,a),f=tO("keys",t,n,r),d=tO("defaultValue",t,n,r),m=a.getHashTableById(h.id),e.next=22,m.find(f,d);case 22:return e.t2=e.sent,e.abrupt("return",[e.t2]);case 24:throw TypeError("Node type "+t.op+" is not implemented");case 25:case"end":return e.stop()}}),e)})));return function(t,n,r,a){return e.apply(this,arguments)}}();function eM(e,t,n,r){var a=function(e,t,n){switch(e.category){case"arithmetic":return dx((function(){return function(e,t,n){switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[xx(tO("a",e,t,n),tO("b",e,t,n))];case"AddN":return[Cx(tO("tensors",e,t,n))];case"FloorMod":case"Mod":return[Wk(tO("a",e,t,n),tO("b",e,t,n))];case"Mul":return[Nx(tO("a",e,t,n),tO("b",e,t,n))];case"RealDiv":case"Div":return[kx(tO("a",e,t,n),tO("b",e,t,n))];case"DivNoNan":return[Pw(tO("a",e,t,n),tO("b",e,t,n))];case"FloorDiv":return[wx(tO("a",e,t,n),tO("b",e,t,n))];case"Sub":return[vk(tO("a",e,t,n),tO("b",e,t,n))];case"Minimum":return[Pk(tO("a",e,t,n),tO("b",e,t,n))];case"Maximum":return[Mk(tO("a",e,t,n),tO("b",e,t,n))];case"Pow":return[rN(tO("a",e,t,n),tO("b",e,t,n))];case"SquaredDifference":return[QN(tO("a",e,t,n),tO("b",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"basic_math":return dx((function(){return function(e,t,n){switch(e.op){case"Abs":case"ComplexAbs":return[Ix(tO("x",e,t,n))];case"Acos":return[Sx(tO("x",e,t,n))];case"Acosh":return[Tx(tO("x",e,t,n))];case"Asin":return[Fx(tO("x",e,t,n))];case"Asinh":return[_x(tO("x",e,t,n))];case"Atan":return[Ox(tO("x",e,t,n))];case"Atan2":return[Mx(tO("x",e,t,n),tO("y",e,t,n))];case"Atanh":return[Lx(tO("x",e,t,n))];case"Ceil":return[pw(tO("x",e,t,n))];case"Complex":return[sy(tO("real",e,t,n),tO("imag",e,t,n))];case"Cos":return[Iw(tO("x",e,t,n))];case"Cosh":return[Sw(tO("x",e,t,n))];case"Elu":return[Ww(tO("x",e,t,n))];case"Erf":return[Vw(tO("x",e,t,n))];case"Exp":return[Uw(tO("x",e,t,n))];case"Expm1":return[jw(tO("x",e,t,n))];case"Floor":return[Xw(tO("x",e,t,n))];case"Log":return[sk(tO("x",e,t,n))];case"Log1p":return[uk(tO("x",e,t,n))];case"Imag":return[Qw(tO("x",e,t,n))];case"Neg":return[hk(tO("x",e,t,n))];case"Reciprocal":return[NN(tO("x",e,t,n))];case"Real":return[kN(tO("x",e,t,n))];case"Relu":return[IN(tO("x",e,t,n))];case"Round":return[DN(tO("x",e,t,n))];case"Selu":return[ON(tO("x",e,t,n))];case"Sigmoid":return[ew(tO("x",e,t,n))];case"Sin":return[BN(tO("x",e,t,n))];case"Sign":return[PN(tO("x",e,t,n))];case"Sinh":return[WN(tO("x",e,t,n))];case"Softplus":return[fk(tO("x",e,t,n))];case"Sqrt":return[ZN(tO("x",e,t,n))];case"Square":return[Vk(tO("x",e,t,n))];case"Tanh":return[nw(tO("x",e,t,n))];case"Tan":return[rI(tO("x",e,t,n))];case"ClipByValue":return[hw(tO("x",e,t,n),tO("clipValueMin",e,t,n),tO("clipValueMax",e,t,n))];case"Relu6":return[SN(tO("x",e,t,n))];case"Rsqrt":return[FN(nO(e.inputNames[0],t,n))];case"Prod":return[iN(tO("x",e,t,n),tO("axes",e,t,n))];case"LeakyRelu":return[nk(tO("x",e,t,n),tO("alpha",e,t,n))];case"Prelu":return[aN(tO("x",e,t,n),tO("alpha",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"control":return XO(e,t,n);case"convolution":return dx((function(){return function(e,t,n){switch(e.op){case"Conv1D":var r=tO("stride",e,t,n),a=tO("pad",e,t,n),i=tO("dataFormat",e,t,n).toUpperCase(),o=tO("dilation",e,t,n);return[yw(tO("x",e,t,n),tO("filter",e,t,n),r,a,i,o)];case"Conv2D":var s=tO("strides",e,t,n),u=oO(e,t,n),l=tO("dataFormat",e,t,n).toUpperCase(),c=tO("dilations",e,t,n);return[gw(tO("x",e,t,n),tO("filter",e,t,n),[s[1],s[2]],u,l,[c[1],c[2]])];case"_FusedConv2D":var p=YO(e,t,n),h=p.stride,f=p.pad,d=p.dataFormat,m=p.dilations,v=p.biasArg,g=p.preluArg,y=p.activationFunc,b=p.leakyreluAlpha;return[KI({x:tO("x",e,t,n),filter:tO("filter",e,t,n),strides:[h[1],h[2]],pad:f,dataFormat:d,dilations:[m[1],m[2]],bias:v,activation:y,preluActivationWeights:g,leakyreluAlpha:b})];case"FusedDepthwiseConv2dNative":var x=YO(e,t,n),w=x.stride,k=x.pad,N=x.dataFormat,I=x.dilations,S=x.biasArg,T=x.preluArg,C=x.activationFunc,E=x.leakyreluAlpha;return[JI({x:tO("x",e,t,n),filter:tO("filter",e,t,n),strides:[w[1],w[2]],pad:k,dataFormat:N,dilations:[I[1],I[2]],bias:S,activation:C,preluActivationWeights:T,leakyreluAlpha:E})];case"Conv2DBackpropInput":case"Conv2dTranspose":var R=tO("outputShape",e,t,n),A=tO("strides",e,t,n),D=oO(e,t,n);return[xw(tO("x",e,t,n),tO("filter",e,t,n),R,[A[1],A[2]],D)];case"DepthwiseConv2dNative":case"DepthwiseConv2d":var F=tO("strides",e,t,n),_=oO(e,t,n),O=tO("dilations",e,t,n),M=tO("dataFormat",e,t,n).toUpperCase();return[Rw(tO("input",e,t,n),tO("filter",e,t,n),[F[1],F[2]],_,M,[O[1],O[2]])];case"Conv3D":var L=tO("strides",e,t,n),z=tO("pad",e,t,n),P=tO("dataFormat",e,t,n).toUpperCase(),B=tO("dilations",e,t,n);return[ww(tO("x",e,t,n),tO("filter",e,t,n),[L[1],L[2],L[3]],z,P,[B[1],B[2],B[3]])];case"AvgPool":var W=tO("strides",e,t,n),V=tO("pad",e,t,n),U=tO("kernelSize",e,t,n);return[Zx(tO("x",e,t,n),[U[1],U[2]],[W[1],W[2]],V)];case"MaxPool":var G=tO("strides",e,t,n),j=tO("pad",e,t,n),H=tO("kernelSize",e,t,n);return[Fk(tO("x",e,t,n),[H[1],H[2]],[G[1],G[2]],j)];case"MaxPoolWithArgmax":var q=tO("strides",e,t,n),K=tO("pad",e,t,n),X=tO("kernelSize",e,t,n),Y=tO("includeBatchInIndex",e,t,n),J=Ok(tO("x",e,t,n),[X[1],X[2]],[q[1],q[2]],K,Y);return[J.result,J.indexes];case"AvgPool3D":var Z=tO("strides",e,t,n),Q=tO("pad",e,t,n),$=tO("kernelSize",e,t,n);return[Qx(tO("x",e,t,n),[$[1],$[2],$[3]],[Z[1],Z[2],Z[3]],Q)];case"MaxPool3D":var ee=tO("strides",e,t,n),te=tO("pad",e,t,n),ne=tO("kernelSize",e,t,n);return[_k(tO("x",e,t,n),[ne[1],ne[2],ne[3]],[ee[1],ee[2],ee[3]],te)];case"Dilation2D":var re=tO("strides",e,t,n),ae=tO("pad",e,t,n),ie=tO("dilations",e,t,n),oe=re[1],se=re[2],ue=ie[1],le=ie[2];return[Dw(tO("x",e,t,n),tO("filter",e,t,n),[oe,se],ae,[ue,le],"NHWC")];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"creation":return dx((function(){return function(e,t,n){switch(e.op){case"Fill":var r=tO("shape",e,t,n),a=tO("dtype",e,t,n);return[Kw(r,tO("value",e,t,n),a)];case"LinSpace":return[ik(tO("start",e,t,n),tO("stop",e,t,n),tO("num",e,t,n))];case"Multinomial":var i=tO("logits",e,t,n),o=tO("numSamples",e,t,n),s=tO("seed",e,t,n);return[jk(i,o,s)];case"OneHot":var u=tO("indices",e,t,n),l=tO("depth",e,t,n),c=tO("onValue",e,t,n),p=tO("offValue",e,t,n);return[Sb(u,l,c,p)];case"Ones":return[Kk(tO("shape",e,t,n),tO("dtype",e,t,n))];case"OnesLike":return[Xk(tO("x",e,t,n))];case"RandomUniform":return[xN(tO("shape",e,t,n),tO("minval",e,t,n),tO("maxval",e,t,n),tO("dtype",e,t,n))];case"Range":return[wN(tO("start",e,t,n),tO("stop",e,t,n),tO("step",e,t,n),tO("dtype",e,t,n))];case"TruncatedNormal":var h=tO("shape",e,t,n),f=tO("mean",e,t,n),d=tO("stdDev",e,t,n),m=tO("seed",e,t,n);return[sI(h,f,d,tO("dtype",e,t,n),m)];case"Zeros":return[qk(tO("shape",e,t,n),tO("dtype",e,t,n))];case"ZerosLike":return[zw(tO("x",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"dynamic":return ZO(e,t,n);case"evaluation":return dx((function(){return function(e,t,n){switch(e.op){case"TopKV2":var r=tO("x",e,t,n),a=tO("k",e,t,n),i=tO("sorted",e,t,n),o=oI(r,a,i);return[o.values,o.indices];case"Unique":var s=tO("x",e,t,n),u=uI(s);return[u.values,u.indices];case"UniqueV2":var l=tO("x",e,t,n),c=tO("axis",e,t,n),p=uI(l,c);return[p.values,p.indices];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"image":return dx((function(){return function(e,t,n){switch(e.op){case"ResizeBilinear":var r=tO("images",e,t,n),a=tO("size",e,t,n),i=tO("alignCorners",e,t,n),o=tO("halfPixelCenters",e,t,n);return[GS.resizeBilinear(r,[a[0],a[1]],i,o)];case"ResizeNearestNeighbor":var s=tO("images",e,t,n),u=tO("size",e,t,n),l=tO("alignCorners",e,t,n),c=tO("halfPixelCenters",e,t,n);return[GS.resizeNearestNeighbor(s,[u[0],u[1]],l,c)];case"CropAndResize":var p=tO("image",e,t,n),h=tO("boxes",e,t,n),f=tO("boxInd",e,t,n),d=tO("cropSize",e,t,n),m=tO("method",e,t,n),v=tO("extrapolationValue",e,t,n);return[GS.cropAndResize(p,h,f,d,m,v)];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"graph":return dx((function(){return function(e,t,n){switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":var r=tO("default",e,t,n);return[nO(e.name,t,n)||r];case"Placeholder":return[nO(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":return[sO(tO("x",e,t,n))];case"IdentityN":return tO("x",e,t,n).map((function(e){return sO(e)}));case"Snapshot":return[sO(tO("x",e,t,n))];case"Shape":return[aI(tO("x",e,t,n).shape,"int32")];case"ShapeN":return tO("x",e,t,n).map((function(e){return aI(e.shape)}));case"Size":return[_N(tO("x",e,t,n).size,"int32")];case"Rank":return[_N(tO("x",e,t,n).rank,"int32")];case"NoOp":return[_N(1)];case"Print":var a=tO("x",e,t,n),i=tO("data",e,t,n),o=tO("message",e,t,n),s=tO("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(var u=0;u<i.length;u++)console.log(Array.prototype.slice.call(i[u].dataSync()).slice(0,s));return[a];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"logical":return dx((function(){return function(e,t,n){switch(e.op){case"Equal":return[Mw(tO("a",e,t,n),tO("b",e,t,n))];case"NotEqual":return[Hk(tO("a",e,t,n),tO("b",e,t,n))];case"Greater":return[Jw(tO("a",e,t,n),tO("b",e,t,n))];case"GreaterEqual":return[Zw(tO("a",e,t,n),tO("b",e,t,n))];case"Less":return[rk(tO("a",e,t,n),tO("b",e,t,n))];case"LessEqual":return[ak(tO("a",e,t,n),tO("b",e,t,n))];case"LogicalAnd":return[Ek(tO("a",e,t,n),tO("b",e,t,n))];case"LogicalNot":return[Rk(tO("a",e,t,n))];case"LogicalOr":return[Ak(tO("a",e,t,n),tO("b",e,t,n))];case"Select":case"SelectV2":return[Lw(tO("condition",e,t,n),tO("a",e,t,n),tO("b",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"matrices":return dx((function(){return function(e,t,n){switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[Ib(tO("a",e,t,n),tO("b",e,t,n),tO("transposeA",e,t,n),tO("transposeB",e,t,n))];case"Transpose":return[Tb(tO("x",e,t,n),tO("perm",e,t,n))];case"_FusedMatMul":var r=tO("fusedOps",e,t,n),a=r[0],i=r[1],o="biasadd"===a,s="prelu"===i,u=tO("numArgs",e,t,n),l=tO("leakyreluAlpha",e,t,n);if(o){if(s&&2!==u)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!s&&1!==u)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}var c=tO("args",e,t,n),p=c[0],h=c[1];return[ZI({a:tO("a",e,t,n),b:tO("b",e,t,n),transposeA:tO("transposeA",e,t,n),transposeB:tO("transposeB",e,t,n),bias:p,activation:i,preluActivationWeights:h,leakyreluAlpha:l})];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"normalization":return dx((function(){return function(e,t,n){switch(e.op){case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[iw(tO("x",e,t,n),tO("mean",e,t,n),tO("variance",e,t,n),tO("offset",e,t,n),tO("scale",e,t,n),tO("epsilon",e,t,n))];case"LRN":return[ok(tO("x",e,t,n),tO("radius",e,t,n),tO("bias",e,t,n),tO("alpha",e,t,n),tO("beta",e,t,n))];case"Softmax":return[HN(tO("x",e,t,n))];case"LogSoftmax":return[yk(tO("x",e,t,n))];case"SparseToDense":return[MI(tO("sparseIndices",e,t,n),tO("outputShape",e,t,n),tO("sparseValues",e,t,n),tO("defaultValue",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"reduction":return dx((function(){return function(e,t,n){switch(e.op){case"Max":var r=tO("axis",e,t,n),a=tO("keepDims",e,t,n);return[mk(tO("x",e,t,n),r,a)];case"Mean":var i=tO("axis",e,t,n),o=tO("keepDims",e,t,n);return[Lk(tO("x",e,t,n),i,o)];case"Min":var s=tO("axis",e,t,n),u=tO("keepDims",e,t,n);return[zk(tO("x",e,t,n),s,u)];case"Sum":var l=tO("axis",e,t,n),c=tO("keepDims",e,t,n);return[gk(tO("x",e,t,n),l,c)];case"All":var p=tO("axis",e,t,n),h=tO("keepDims",e,t,n);return[Ex(tO("x",e,t,n),p,h)];case"Any":var f=tO("axis",e,t,n),d=tO("keepDims",e,t,n);return[Rx(tO("x",e,t,n),f,d)];case"ArgMax":var m=tO("axis",e,t,n);return[Ax(tO("x",e,t,n),m)];case"ArgMin":var v=tO("axis",e,t,n);return[Dx(tO("x",e,t,n),v)];case"Prod":var g=tO("axis",e,t,n),y=tO("keepDims",e,t,n);return[iN(tO("x",e,t,n),g,y)];case"Cumsum":var b=tO("axis",e,t,n),x=tO("exclusive",e,t,n),w=tO("reverse",e,t,n);return[Tw(tO("x",e,t,n),b,x,w)];case"Bincount":var k=tO("x",e,t,n),N=tO("weights",e,t,n),I=tO("size",e,t,n);return[lw(k,N,I)];case"DenseBincount":var S=tO("x",e,t,n),T=tO("weights",e,t,n),C=tO("size",e,t,n),E=tO("binaryOutput",e,t,n);return[Cw(S,T,C,E)];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"slice_join":return dx((function(){return function(e,t,n){switch(e.op){case"ConcatV2":case"Concat":var r=tO("n",e,t,n),a=tO("axis",e,t,n),i=tO("tensors",e,t,n);return i=i.slice(0,r),[$x(i,a)];case"Gather":var o=tO("x",e,t,n),s=tO("indices",e,t,n);return[Yw(o,rb(s,"int32"),0)];case"GatherV2":var u=tO("axis",e,t,n),l=tO("batchDims",e,t,n),c=tO("x",e,t,n),p=tO("indices",e,t,n);return[Yw(c,rb(p,"int32"),u,l)];case"Reverse":for(var h=tO("dims",e,t,n),f=[],d=0;d<h.length;d++)h[d]&&f.push(d);var m=tO("x",e,t,n);return[TN(m,f)];case"ReverseV2":var v=tO("axis",e,t,n),g=tO("x",e,t,n);return[TN(g,v)];case"Slice":var y=tO("begin",e,t,n),b=tO("size",e,t,n);return[tw(tO("x",e,t,n),y,b)];case"StridedSlice":var x=tO("begin",e,t,n),w=tO("end",e,t,n),k=tO("strides",e,t,n),N=tO("beginMask",e,t,n),I=tO("endMask",e,t,n),S=tO("ellipsisMask",e,t,n),T=tO("newAxisMask",e,t,n),C=tO("shrinkAxisMask",e,t,n),E=tO("x",e,t,n);return[nI(E,x,w,k,N,I,S,T,C)];case"Pack":return dx((function(){var r=tO("axis",e,t,n),a=tO("tensors",e,t,n),i=a[0].shape,o=$N(a[0]).shape,s=a.map((function(e){var t=dv(e.shape,i);if(!t&&!dv($N(e).shape,o))throw new Error("the input tensors shape does not match");return t?e:Jx(e,i)}));return[eI(s,r)]}));case"Unpack":var R=tO("axis",e,t,n),A=tO("tensor",e,t,n);return cI(A,R);case"Tile":var D=tO("reps",e,t,n);return[Hw(tO("x",e,t,n),D)];case"Split":case"SplitV":var F=tO("axis",e,t,n),_=tO("numOrSizeSplits",e,t,n),O=tO("x",e,t,n);return YN(O,_,F);case"ScatterNd":var M=tO("indices",e,t,n),L=tO("values",e,t,n),z=tO("shape",e,t,n);return[OI(M,L,z)];case"GatherNd":var P=tO("x",e,t,n),B=tO("indices",e,t,n);return[LI(P,B)];case"SparseToDense":var W=tO("sparseIndices",e,t,n),V=tO("outputShape",e,t,n),U=tO("sparseValues",e,t,n),G=tO("defaultValue",e,t,n);return[MI(W,U,V,U.dtype===G.dtype?G:rb(G,U.dtype))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"spectral":return dx((function(){return function(e,t,n){switch(e.op){case"FFT":return[qN(tO("x",e,t,n))];case"IFFT":return[KN(tO("x",e,t,n))];case"RFFT":return[JN(tO("x",e,t,n))];case"IRFFT":return[XN(tO("x",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"transformation":return dx((function(){return function(e,t,n){switch(e.op){case"Cast":return[rb(tO("x",e,t,n),tO("dtype",e,t,n))];case"ExpandDims":var r=tO("axis",e,t,n);return[Gw(tO("x",e,t,n),r)];case"Squeeze":var a=tO("axis",e,t,n);return[$N(tO("x",e,t,n),a)];case"Reshape":return[Jx(tO("x",e,t,n),tO("shape",e,t,n))];case"MirrorPad":return[Bk(tO("x",e,t,n),tO("padding",e,t,n),tO("mode",e,t,n))];case"PadV2":case"Pad":return[Jk(tO("x",e,t,n),tO("padding",e,t,n),tO("constantValue",e,t,n))];case"SpaceToBatchND":var i=tO("blockShape",e,t,n),o=tO("paddings",e,t,n);return[tN(tO("x",e,t,n),i,o)];case"BatchToSpaceND":var s=tO("blockShape",e,t,n),u=tO("crops",e,t,n);return[aw(tO("x",e,t,n),s,u)];case"DepthToSpace":var l=tO("blockSize",e,t,n),c=tO("dataFormat",e,t,n).toUpperCase();return[Ew(tO("x",e,t,n),l,c)];case"BroadcastTo":return[cw(tO("x",e,t,n),tO("shape",e,t,n))];default:throw TypeError("Node type "+e.op+" is not implemented")}}(e,t,n)}));case"hash_table":return $O(e,t,n,r);case"custom":var a=eO(e.op);if(a&&a.customExecutor)return a.customExecutor(new WO(e,t,n));throw TypeError("Custom op "+e.op+" is not registered.");default:throw TypeError("Unknown op '"+e.op+"'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()")}}(e,t,n);return jv(a)?a.then((function(e){return[].concat(e)})):[].concat(a)}var tM=function(){function e(e,t,n,r){void 0===e&&(e={}),void 0===t&&(t={}),void 0===n&&(n={}),void 0===r&&(r={}),this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}var t=e.prototype;return t.newFrame=function(e,t){return{id:e,frameName:t,iterationId:0}},t.generateCurrentContextIds=function(){for(var e=[],t=0;t<this.contexts.length-1;t++){var n=this.contexts.slice(0,this.contexts.length-t);e.push(this.contextIdforContexts(n))}e.push(""),this._currentContextIds=e},t.contextIdforContexts=function(e){return e?e.map((function(e){return 0===e.id&&0===e.iterationId?"":e.frameName+"-"+e.iterationId})).join("/"):""},t.enterFrame=function(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))},t.exitFrame=function(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()},t.nextIteration=function(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");this.contexts=this.contexts.slice(),this.lastId++;var e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))},t.getWeight=function(e){return this.weightMap[e]},t.addTensorArray=function(e){this.tensorArrayMap[e.id]=e},t.getTensorArray=function(e){return this.tensorArrayMap[e]},t.addTensorList=function(e){this.tensorListMap[e.id]=e},t.getTensorList=function(e){return this.tensorListMap[e]},t.dispose=function(e){for(var t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(var n in this.tensorListMap)this.tensorListMap[n].clearAndClose(e)},Hm(e,[{key:"currentContext",set:function(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())},get:function(){return this.contexts}},{key:"currentContextId",get:function(){return this._currentContextIds[0]}},{key:"currentContextIds",get:function(){return this._currentContextIds}}]),e}();function nM(e,t,n,r){var a=new Set,i=[],o=null,s=null,u=new Set,l=Object.keys(e).map((function(e){return iO(e)[0]})),c=[];null!=r&&(c=r.map((function(e){return iO(e.name)[0]})));for(var p=[].concat(t);p.length>0;){var h=p.pop();(oM(h)||sM(h)||uM(h))&&null==o&&(s=(o=h).children.map((function(e){return e.name})).filter((function(e){return a.has(e)}))),a.add(h.name),null==n[h.name]&&(-1===l.indexOf(h.name)&&-1===c.indexOf(h.name)&&(0!==h.inputs.length?h.inputs.forEach((function(e){u.has(e.name)||(u.add(e.name),p.push(e))})):i.push(h.name)))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:i,dynamicNode:o,syncInputs:s}}var rM=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],aM=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],iM=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2"];function oM(e){return rM.indexOf(e.op)>=0}function sM(e){return aM.indexOf(e.op)>=0}function uM(e){return iM.indexOf(e.op)>=0}var lM=function(){function e(t,n){var r=this;this.graph=t,this.parent=n,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this._outputs=t.outputs,this._inputs=t.inputs,this._initNodes=t.initNodes,this._signature=t.signature,this._functions=t.functions,null!=t.functions&&Object.keys(t.functions).forEach((function(n){r._functionExecutorMap[n]=new e(t.functions[n],r)}))}var t=e.prototype;return t.getCompilationKey=function(e,t){var n=e.map((function(e){return e.name})).sort(),r=t.map((function(e){return e.name})).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)},t.compile=function(e,t){var n=nM(e,t,this.weightMap,this._initNodes),r=n.missingInputs,a=n.dynamicNode,i=n.syncInputs;if(null!=a)throw new Error("This execution contains the node '"+a.name+"', which has the dynamic op '"+a.op+"'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs ["+i+"]");if(r.length>0){var o=t.map((function(e){return e.name})),s=Object.keys(e);throw new Error("Cannot compute the outputs ["+o+"] from the provided inputs ["+s+"]. Missing the following inputs: ["+r+"]")}return function(e,t,n){var r=n.usedNodes,a=n.inputs,i=[],o=Object.keys(a).map((function(e){return iO(e)[0]})).map((function(t){return e.nodes[t]})),s=e.initNodes;o.forEach((function(e){r.has(e.name)&&i.push(e)})),e.weights.forEach((function(e){r.has(e.name)&&i.push(e)})),null!=s&&s.forEach((function(e){r.has(e.name)&&i.push(e)}));for(var u=new Set,l=[];i.length>0;){var c=i.pop();u.add(c.name),t[c.name]||l.push(c),c.children.forEach((function(e){!u.has(e.name)&&r.has(e.name)&&e.inputs.every((function(e){return u.has(e.name)}))&&i.push(e)}))}return l}(this.graph,this.weightMap,n)},t.execute=function(e,t){var n=this;e=this.mapInputs(e);var r=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);var a=r.map((function(e){return n.graph.nodes[iO(e)[0]]})),i=t.map((function(e){return iO(e)[0]})),o=i.map((function(e){return n.graph.nodes[e]}));0===o.length&&(o=this._outputs);var s=this.getCompilationKey(a,o),u=this.compiledMap.get(s);null==u&&(u=this.compile(e,o),this.compiledMap.set(s,u));var l={},c={};return dx((function(){var r=new tM(n.weightMap,l,c,n.functionExecutorMap),a=Object.assign({},n.weightMap);Object.keys(e).forEach((function(t){var n=iO(t),r=n[0],i=[];i[n[1]]=e[t],a[r]=i}));for(var o=n.getFrozenTensorIds(a),s={},p=0;p<u.length;p++){var h=u[p];if(!a[h.name]){var f=eM(h,a,r,n._resourceManager);if(jv(f))throw new Error("The execution of the op '"+h.op+"' returned a promise. Please use model.executeAsync() instead.");a[h.name]=f,n.checkTensorForDisposal(h.name,h,a,r,o,i,s)}}return null==n.parent&&r.dispose(o),t.map((function(e){return nO(e,a,r)}))}))},t.getFrozenTensorIds=function(e){var t=[].concat.apply([],Object.keys(e).map((function(t){return e[t]})).map((function(e){return e.map((function(e){return e.id}))})));return new Set(t)},t.checkTensorForDisposal=function(e,t,n,r,a,i,o){"control"!==t.category&&-1===i.indexOf(e)&&(n[e].forEach((function(e){null!=e&&(o[e.id]=(o[e.id]||0)+t.children.length)})),t.inputs.forEach((function(e){if("control"!==e.category){var t=function(e,t,n){return t[aO(e,n.currentContextId)]}(e.name,n,r);null!=t&&t.forEach((function(e){if(e&&!a.has(e.id)){var t=o[e.id];1===t?(e.dispose(),delete o[e.id]):null!=t&&o[e.id]--}}))}})))},t.executeAsync=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._executeAsync(t,n));case 1:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t._executeAsync=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n,r,a,i){var o,s,u,l,c,p;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r=!1),void 0===a&&(a={}),void 0===i&&(i={}),r||(t=this.mapInputs(t),this.checkInputs(t),this.checkInputShapeAndType(t),n=this.mapOutputs(n),this.checkOutputs(n)),o=new tM(this.weightMap,a,i,this.functionExecutorMap),e.next=7,this.executeWithControlFlow(t,o,n,r);case 7:return s=e.sent,u=n.map((function(e){return nO(e,s,o)})),l=u.map((function(e){return e.id})),c=Object.keys(t).map((function(e){return t[e].id})),p=new Set([].concat(l,c,this.weightIds)),Object.keys(s).forEach((function(e){s[e].forEach((function(e){!e||e.isDisposed||p.has(e.id)||e.dispose()}))})),null==this.parent&&o.dispose(p),e.abrupt("return",u);case 15:case"end":return e.stop()}}),e,this)})));return function(t,n,r,a,i){return e.apply(this,arguments)}}(),t.executeFunctionAsync=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n,r){var a,i=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.reduce((function(e,t,n){return e[i.inputs[n].name]=t,e}),{}),e.abrupt("return",this._executeAsync(a,this.outputNodes,!0,n,r));case 2:case"end":return e.stop()}}),e,this)})));return function(t,n,r){return e.apply(this,arguments)}}(),t.executeWithControlFlow=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n,r,a){var i,o,s,u,l,c,p,h,f,d,m,v,g,y,b,x,w,k=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=Object.keys(t),o=i.map((function(e){return k.graph.nodes[iO(e)[0]]})),s=r.map((function(e){return iO(e)[0]})),0===(u=s.map((function(e){return k.graph.nodes[e]}))).length&&(u=this._outputs),l=nM(t,u,this.weightMap,this._initNodes),c=l.usedNodes,p=l.missingInputs,h=l.dynamicNode,f=l.syncInputs,d=[].concat(o,this.graph.weights,this._initNodes||[]).map((function(e){return{node:e,contexts:n.currentContext}})),m=Object.assign({},this.weightMap),Object.keys(t).forEach((function(e){var n=iO(e),r=n[0],a=[];a[n[1]]=t[e],m[r]=a})),v={},g=this.getFrozenTensorIds(m),y={};case 12:if(!(d.length>0)){e.next=18;break}return b=this.processStack(o,d,n,m,y,g,s,v,c),e.next=16,Promise.all(b);case 16:e.next=12;break;case 18:if(null!=h||a||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead."),!((x=u.filter((function(e){return!oM(e)&&!nO(e.name,m,n)})).map((function(e){return e.name}))).length>0)){e.next=24;break}throw w="",null!=h&&(w="Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs ["+f+"]"),new Error("Cannot compute the outputs ["+x+"] from the provided inputs ["+i+"]. Consider providing the following inputs: ["+p+"]. "+w);case 24:return e.abrupt("return",m);case 25:case"end":return e.stop()}}),e,this)})));return function(t,n,r,a){return e.apply(this,arguments)}}(),t.processStack=function(e,t,n,r,a,i,o,s,u){for(var l=this,c=[],p=function(){var e=t.pop();n.currentContext=e.contexts;var p="";if("Enter"===e.node.op&&tO("isConstant",e.node,r,n)){var h=rO(e.node.name,n);p=h[0]}if(null==r[e.node.name]){var f=eM(e.node,r,n,l._resourceManager);if(!p){var d=rO(e.node.name,n);p=d[0]}var m=n.currentContext;jv(f)?c.push(f.then((function(c){return r[p]=c,n.currentContext=m,l.checkTensorForDisposal(p,e.node,r,n,i,o,s),l.processChildNodes(e.node,t,n,r,a,u),c}))):(r[p]=f,l.checkTensorForDisposal(p,e.node,r,n,i,o,s),l.processChildNodes(e.node,t,n,r,a,u))}else l.processChildNodes(e.node,t,n,r,a,u)};t.length>0;)p();return c},t.processChildNodes=function(e,t,n,r,a,i){e.children.forEach((function(e){var o=rO(e.name,n)[0];!a[o]&&i.has(e.name)&&("Merge"===e.op?e.inputNames.some((function(e){return!!nO(e,r,n)}))&&(a[o]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every((function(e){return!!nO(e,r,n)}))&&(a[o]=!0,t.push({contexts:n.currentContext,node:e})))}))},t.dispose=function(){var e=this;Object.keys(this.weightMap).forEach((function(t){return e.weightMap[t].forEach((function(e){return e.dispose()}))}))},t.checkInputShapeAndType=function(e){var t=this;Object.keys(e).forEach((function(n){var r=e[n],a=iO(n)[0],i=t.graph.nodes[a];if(i.attrParams.shape&&i.attrParams.shape.value){var o=i.attrParams.shape.value;lv(o.length===r.shape.length&&r.shape.every((function(e,t){return-1===o[t]||o[t]===e})),(function(){return"The shape of dict['"+i.name+"'] provided in model.execute(dict) must be ["+o+"], but was ["+r.shape+"]"}))}i.attrParams.dtype&&i.attrParams.dtype.value&&lv(r.dtype===i.attrParams.dtype.value,(function(){return"The dtype of dict['"+i.name+"'] provided in model.execute(dict) must be "+i.attrParams.dtype.value+", but was "+r.dtype}))}))},t.mapInputs=function(e){var t={};for(var n in e){if(null!=this._signature&&null!=this._signature.inputs&&null!=this._signature.inputs[n])t[this._signature.inputs[n].name]=e[n];else t[n]=e[n]}return t},t.checkInputs=function(e){var t=this,n=Object.keys(e).filter((function(e){var n=iO(e)[0];return null==t.graph.nodes[n]}));if(n.length>0)throw new Error("The dict provided in model.execute(dict) has keys: ["+n+"] that are not part of graph")},t.mapOutputs=function(e){var t=this;return e.map((function(e){return null!=t._signature&&null!=t._signature.outputs&&null!=t._signature.outputs[e]?t._signature.outputs[e].name:e}),{})},t.checkOutputs=function(e){var t=this;e.forEach((function(e){var n=iO(e)[0];if(!t.graph.nodes[n])throw new Error("The output '"+e+"' is not found in the graph")}))},Hm(e,[{key:"weightIds",get:function(){return this.parent?this.parent.weightIds:this._weightIds}},{key:"functionExecutorMap",get:function(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}},{key:"weightMap",get:function(){return this.parent?this.parent.weightMap:this._weightMap},set:function(e){var t,n=Object.keys(e).map((function(t){return e[t].map((function(e){return e.id}))}));this._weightIds=(t=[]).concat.apply(t,n),this._weightMap=e}},{key:"resourceManager",set:function(e){this._resourceManager=e}},{key:"inputs",get:function(){return this._inputs.map((function(e){return{name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}}))}},{key:"outputs",get:function(){return this._outputs.map((function(e){return{name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0}}))}},{key:"inputNodes",get:function(){return this._inputs.map((function(e){return e.signatureKey||e.name}))}},{key:"outputNodes",get:function(){return this._outputs.map((function(e){var t=e.signatureKey||e.name;return e.defaultOutput?t+":"+e.defaultOutput:t}))}},{key:"functions",get:function(){var e=this;return Object.keys(this._functions).reduce((function(t,n){return t[n]=e._functions[n].signature,t}),{})}}]),e}(),cM=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.hashTableNameToHandle=e,this.hashTableMap=t}var t=e.prototype;return t.addHashTable=function(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t},t.getHashTableHandleByName=function(e){return this.hashTableNameToHandle[e]},t.getHashTableById=function(e){return this.hashTableMap[e]},t.dispose=function(){for(var e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(var t in this.hashTableNameToHandle)this.hashTableNameToHandle[t].dispose(),delete this.hashTableNameToHandle[t]},e}(),pM=function(){function e(e,t){void 0===t&&(t={}),this.modelUrl=e,this.loadOptions=t,this.version="n/a",null==t&&(this.loadOptions={}),this.resourceManager=new cM}var t=e.prototype;return t.findIOHandler=function(){var e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=xb(e,this.loadOptions);else{var t=Sy(e,this.loadOptions);if(0===t.length)t.push(xb(e,this.loadOptions));else if(t.length>1)throw new Error("Found more than one ("+t.length+") load handlers for URL '"+[e]+"'");this.handler=t[0]}},t.load=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.findIOHandler(),null!=this.handler.load){e.next=3;break}throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");case 3:return e.next=5,this.handler.load();case 5:return t=e.sent,e.abrupt("return",this.loadSync(t));case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.loadSync=function(e){this.artifacts=e;var t,n=this.artifacts.modelTopology;this.isOldVersion(e.convertedBy)?null!=this.artifacts.userDefinedMetadata&&(t=this.artifacts.userDefinedMetadata.signature):t=this.artifacts.signature,this.version=n.versions.producer+"."+n.versions.minConsumer;var r=fy(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new lM(SO.Instance.transformGraph(n,t)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){var a=SO.Instance.transformGraph(e.modelInitializer);this.initializer=new lM(a),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializer.executeAsync({},[])}return!0},t.isOldVersion=function(e){if(e){var t=e.split("TensorFlow.js Converter v");t=t[0].split(".");var n=parseInt(t[0],10),r=parseInt(t[1],10);return n<=1||2===n&&r<=7}return!0},t.save=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t){e.next=9;break}if(0!==(r=Iy(t)).length){e.next=6;break}throw new Error("Cannot find any save handlers for URL '"+t+"'");case 6:if(!(r.length>1)){e.next=8;break}throw new Error("Found more than one ("+r.length+") save handlers for URL '"+t+"'");case 8:t=r[0];case 9:if(null!=t.save){e.next=11;break}throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");case 11:return e.abrupt("return",t.save(this.artifacts));case 12:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.predict=function(e,t){return this.execute(e,this.outputNodes)},t.normalizeInputs=function(e){if(!(e instanceof Fg||Array.isArray(e)))return e;if((e=Array.isArray(e)?e:[e]).length!==this.inputNodes.length)throw new Error("Input tensor count mismatch,the graph model has "+this.inputNodes.length+" placeholders, while there are "+e.length+" input tensors.");return this.inputNodes.reduce((function(t,n,r){return t[n]=e[r],t}),{})},t.normalizeOutputs=function(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]},t.execute=function(e,t){e=this.normalizeInputs(e),t=this.normalizeOutputs(t);var n=this.executor.execute(e,t);return n.length>1?n:n[0]},t.executeAsync=function(){var e=Gm(regeneratorRuntime.mark((function e(t,n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.normalizeInputs(t),n=this.normalizeOutputs(n),e.next=4,this.executor.executeAsync(t,n);case 4:return r=e.sent,e.abrupt("return",r.length>1?r:r[0]);case 6:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),t.convertTensorMapToTensorsMap=function(e){return Object.keys(e).reduce((function(t,n){return t[n]=[e[n]],t}),{})},t.dispose=function(){this.executor.dispose(),this.initializer&&this.initializer.dispose(),this.resourceManager.dispose()},Hm(e,[{key:"modelVersion",get:function(){return this.version}},{key:"inputNodes",get:function(){return this.executor.inputNodes}},{key:"outputNodes",get:function(){return this.executor.outputNodes}},{key:"inputs",get:function(){return this.executor.inputs}},{key:"outputs",get:function(){return this.executor.outputs}},{key:"weights",get:function(){return this.executor.weightMap}},{key:"metadata",get:function(){return this.artifacts.userDefinedMetadata}}]),e}();function hM(){return(hM=Gm(regeneratorRuntime.mark((function e(t,n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n={}),null!=t){e.next=3;break}throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");case 3:return null==n&&(n={}),n.fromTFHub&&null==t.load&&(t.endsWith("/")||(t+="/"),t+="model.json?tfjs-format=file"),r=new pM(t,n),e.next=8,r.load();case 8:return e.abrupt("return",r);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fM(e,t,n,r){if(void 0===n&&(n=new Map),void 0===r&&(r=new Set),null==e)return null;if(r.has(e))throw new Error("Circular references are not supported.");if(n.has(e))return n.get(e);var a=t(e);if(a.recurse&&null!==a.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(a.recurse){if(yM(e)){var i=Array.isArray(e)?[]:{};for(var o in r.add(e),e){var s=fM(e[o],t,n,r);i[o]=s}return r.delete(e),i}throw new Error("Can't recurse into non-iterable type: "+e)}return n.set(e,a.value),a.value}function dM(e,t){return void 0===t&&(t=mM),function e(t,n,r){void 0===r&&(r=new Set);var a=t[0];if(r.has(a))throw new Error("Circular references are not supported.");var i=n(t);if(i.recurse&&null!==i.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(i.recurse){if(yM(a)){var o=Array.isArray(a)?[]:{};r.add(a);var s=function(a){var i=t.map((function(e){return e[a]})),s=e(i,n,r);o[a]=s};for(var u in a)s(u);return r.delete(a),o}throw new Error("Can't recurse into non-iterable type: "+a)}return i.value}(e,t)}function mM(e){return null===e?null:yM(e[0])?{value:null,recurse:!0}:{value:e,recurse:!1}}function vM(e,t){return gM.apply(this,arguments)}function gM(){return(gM=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i,o,s,u,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=new Map,fM(t,n,r),a=0,i=Array.from(r.keys());case 3:if(!(a<i.length)){e.next=14;break}if(o=i[a],!jv(s=r.get(o))){e.next=11;break}return e.next=9,s;case 9:u=e.sent,r.set(o,u);case 11:a++,e.next=3;break;case 14:return l=fM(t,n,r),e.abrupt("return",l);case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yM(e){return null!=e&&!ArrayBuffer.isView(e)&&(Array.isArray(e)||"object"==typeof e&&!(e instanceof Fg))}function bM(e){return function(e,t){return fM(e,t)}(e,xM)}function xM(e){return e instanceof Fg?{value:e.clone(),recurse:!1}:yM(e)?{value:null,recurse:!0}:{value:e,recurse:!1}}var wM=function(){function e(e){if(this.capacity=e,this.begin=0,this.end=0,null==e)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(e<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(e),this.doubledCapacity=2*e}var t=e.prototype;return t.wrap=function(e){for(;e<0;)e+=this.doubledCapacity;return e%this.doubledCapacity},t.get=function(e){if(e<0)throw new RangeError("Can't get item at a negative index.");return this.data[e%this.capacity]},t.set=function(e,t){if(e<0)throw new RangeError("Can't set item at a negative index.");this.data[e%this.capacity]=t},t.length=function(){var e=this.end-this.begin;return e<0&&(e=this.doubledCapacity+e),e},t.isFull=function(){return this.length()===this.capacity},t.isEmpty=function(){return 0===this.length()},t.push=function(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,e),this.end=this.wrap(this.end+1)},t.pushAll=function(e){for(var t,n=tv(e);!(t=n()).done;){var r=t.value;this.push(r)}},t.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var e=this.get(this.end);return this.set(this.end,void 0),e},t.unshift=function(e){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,e)},t.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),e},t.shuffleExcise=function(e){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.wrap(this.begin+e),n=this.get(t);return this.set(t,this.pop()),n},e}(),kM=function(e){function t(){return e.call(this,t.INITIAL_CAPACITY)||this}qm(t,e);var n=t.prototype;return n.isFull=function(){return!1},n.push=function(t){e.prototype.isFull.call(this)&&this.expand(),e.prototype.push.call(this,t)},n.unshift=function(t){e.prototype.isFull.call(this)&&this.expand(),e.prototype.unshift.call(this,t)},n.expand=function(){for(var e=2*this.capacity,t=new Array(e),n=this.length(),r=0;r<n;r++)t[r]=this.get(this.wrap(this.begin+r));this.data=t,this.capacity=e,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n},t}(wM);function NM(e){return new RM(e)}function IM(e){return new AM(e)}function SM(e,t){return new VM(e,t)}function TM(e,t){return void 0===t&&(t=CM.FAIL),new UM(e,t)}kM.INITIAL_CAPACITY=32;var CM,EM=function(){function e(){}var t=e.prototype;return t.toArray=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,this.next();case 3:n=e.sent;case 4:if(n.done){e.next=11;break}return t.push(n.value),e.next=8,this.next();case 8:n=e.sent,e.next=4;break;case 11:return e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.toArrayForTest=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.prefetch(100),n=[],e.next=4,t.next();case 4:r=e.sent;case 5:if(r.done){e.next=12;break}return n.push(r.value),e.next=9,t.next();case 9:r=e.sent,e.next=5;break;case 12:return e.abrupt("return",n);case 13:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.resolveFully=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.next();case 2:t=e.sent;case 3:if(t.done){e.next=9;break}return e.next=6,this.next();case 6:t=e.sent,e.next=3;break;case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.resolveWhile=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.next();case 2:n=e.sent,r=t(n.value);case 4:if(n.done||!r){e.next=11;break}return e.next=7,this.next();case 7:n=e.sent,r=t(n.value),e.next=4;break;case 11:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.handleErrors=function(e){return new zM(this,e)},t.filter=function(e){return new MM(this,e)},t.map=function(e){return new LM(this,e)},t.mapAsync=function(e){return new PM(this,e)},t.serialMapAsync=function(e){return new PM(this,e).serial()},t.flatmap=function(e){return new WM(this,e)},t.forEachAsync=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.map(t).resolveFully());case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.serialForEach=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.serialMapAsync(t).resolveWhile((function(e){return!0===e})));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.rowMajorBatch=function(e,t){return void 0===t&&(t=!0),new OM(this,e,t)},t.columnMajorBatch=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=mM),this.rowMajorBatch(e,t).map((function(e){return dM(e,n)}))},t.concatenate=function(e,t){return new VM(NM([this,e]),t)},t.take=function(e){return e<0||null==e?this:new _M(this,e)},t.skip=function(e){return e<0||null==e?this:new FM(this,e)},t.prefetch=function(e){return new GM(this,e)},t.shuffle=function(e,t){return new jM(this,e,t)},t.serial=function(){return new DM(this)},e}(),RM=function(e){function t(t){var n;return(n=e.call(this)||this).items=t,n.trav=0,n}qm(t,e);var n=t.prototype;return n.summary=function(){return"Array of "+this.items.length+" items"},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.trav>=this.items.length)){e.next=2;break}return e.abrupt("return",{value:null,done:!0});case 2:return t=this.items[this.trav],this.trav++,e.abrupt("return",{value:bM(t),done:!1});case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(EM),AM=function(e){function t(t){var n;return(n=e.call(this)||this).nextFn=t,n}qm(t,e);var n=t.prototype;return n.summary=function(){return"Function call"},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.abrupt("return",this.nextFn());case 4:throw e.prev=4,e.t0=e.catch(0),e.t0.message="Error thrown while iterating through a dataset: "+e.t0.message,e.t0;case 8:case"end":return e.stop()}}),e,this,[[0,4]])})));return function(){return e.apply(this,arguments)}}(),t}(EM),DM=function(e){function t(t){var n;return(n=e.call(this)||this).upstream=t,n.lastRead=Promise.resolve({value:null,done:!1}),n}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Serial"},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.upstream.next());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(EM),FM=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Skip"},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.count++<this.maxCount)){e.next=9;break}return e.next=3,this.upstream.next();case 3:if(!(t=e.sent).done){e.next=6;break}return e.abrupt("return",t);case 6:mx(t.value),e.next=0;break;case 9:return e.abrupt("return",this.upstream.next());case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(EM),_M=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.maxCount=n,r.count=0,r}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Take"},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.count++>=this.maxCount)){e.next=2;break}return e.abrupt("return",{value:null,done:!0});case 2:return e.abrupt("return",this.upstream.next());case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(EM),OM=function(e){function t(t,n,r){var a;return void 0===r&&(r=!0),(a=e.call(this)||this).upstream=t,a.batchSize=n,a.enableSmallLastBatch=r,a.lastRead=Promise.resolve({value:null,done:!1}),a}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> RowMajorBatch"},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[];case 1:if(!(t.length<this.batchSize)){e.next=12;break}return e.next=4,this.upstream.next();case 4:if(!(n=e.sent).done){e.next=9;break}if(!(this.enableSmallLastBatch&&t.length>0)){e.next=8;break}return e.abrupt("return",{value:t,done:!1});case 8:return e.abrupt("return",{value:null,done:!0});case 9:t.push(n.value),e.next=1;break;case 12:return e.abrupt("return",{value:t,done:!1});case 13:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(EM),MM=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Filter"},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,this.upstream.next();case 3:if(!(t=e.sent).done&&!this.predicate(t.value)){e.next=6;break}return e.abrupt("return",t);case 6:mx(t.value),e.next=0;break;case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(EM),LM=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.transform=n,r}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Map"},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a,i,o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.upstream.next();case 2:if(!(t=e.sent).done){e.next=5;break}return e.abrupt("return",{value:null,done:!0});case 5:for(n=Hg(t.value),r=this.transform(t.value),a=Hg(r),i=tv(n);!(o=i()).done;)jg(s=o.value,a)||s.dispose();return e.abrupt("return",{value:r,done:!1});case 10:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(EM),zM=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> handleErrors"},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=1,e.next=4,this.upstream.next();case 4:return e.abrupt("return",e.sent);case 7:if(e.prev=7,e.t0=e.catch(1),this.handler(e.t0)){e.next=11;break}return e.abrupt("return",{value:null,done:!0});case 11:e.next=0;break;case 13:case"end":return e.stop()}}),e,this,[[1,7]])})));return function(){return e.apply(this,arguments)}}(),t}(EM),PM=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.transform=n,r}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> AsyncMap"},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a,i,o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.upstream.next();case 2:if(!(t=e.sent).done){e.next=5;break}return e.abrupt("return",{value:null,done:!0});case 5:return n=Hg(t.value),e.next=8,this.transform(t.value);case 8:for(r=e.sent,a=Hg(r),i=tv(n);!(o=i()).done;)jg(s=o.value,a)||s.dispose();return e.abrupt("return",{value:r,done:!1});case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(EM),BM=function(e){function t(){var t;return(t=e.call(this)||this).outputQueue=new kM,t.lastRead=Promise.resolve({value:null,done:!1}),t}qm(t,e);var n=t.prototype;return n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.serialNext=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this.outputQueue.length()){e.next=7;break}return e.next=3,this.pump();case 3:if(e.sent){e.next=5;break}return e.abrupt("return",{value:null,done:!0});case 5:e.next=0;break;case 7:return e.abrupt("return",{value:this.outputQueue.shift(),done:!1});case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(EM),WM=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.transform=n,r}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Flatmap"},n.pump=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a,i,o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.upstream.next();case 2:if(!(t=e.sent).done){e.next=5;break}return e.abrupt("return",!1);case 5:for(n=Hg(t.value),r=this.transform(t.value),a=Hg(r),this.outputQueue.pushAll(r),i=tv(n);!(o=i()).done;)jg(s=o.value,a)||s.dispose();return e.abrupt("return",!0);case 11:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(BM),VM=function(e){function t(t,n){var r;return(r=e.call(this)||this).baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=t,r}qm(t,e);var n=t.prototype;return n.summary=function(){return"TODO: fill in upstream of chained summaries -> Chained"},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.readFromChain(this.lastRead),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.readFromChain=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t;case 2:if(null!=this.iterator){e.next=10;break}return e.next=5,this.moreIterators.next();case 5:if(!(n=e.sent).done){e.next=8;break}return e.abrupt("return",{value:null,done:!0});case 8:this.iterator=n.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler));case 10:return e.next=12,this.iterator.next();case 12:if(!(r=e.sent).done){e.next=16;break}return this.iterator=null,e.abrupt("return",this.readFromChain(t));case 16:return e.abrupt("return",r);case 17:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(EM);!function(e){e[e.FAIL=0]="FAIL",e[e.SHORTEST=1]="SHORTEST",e[e.LONGEST=2]="LONGEST"}(CM||(CM={}));var UM=function(e){function t(t,n){var r;return void 0===n&&(n=CM.FAIL),(r=e.call(this)||this).iterators=t,r.mismatchMode=n,r.count=0,r.currentPromise=null,r}qm(t,e);var n=t.prototype;return n.summary=function(){return"{TODO: fill in upstream of zip summaries} -> Zip"},n.nextState=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=function(e){return e instanceof EM?{value:e.next().then((function(e){return n++,e.done&&r++,e.value})),recurse:!1}:{value:null,recurse:!0}},e.next=3,t;case 3:return n=0,r=0,e.next=7,vM(this.iterators,a);case 7:if(i=e.sent,n!==r){e.next=10;break}return e.abrupt("return",{value:null,done:!0});case 10:if(!(r>0)){e.next=16;break}e.t0=this.mismatchMode,e.next=e.t0===CM.FAIL?14:e.t0===CM.SHORTEST?15:(e.t0,CM.LONGEST,16);break;case 14:throw new Error("Zipped streams should have the same length. Mismatched at element "+this.count+".");case 15:return e.abrupt("return",{value:null,done:!0});case 16:return this.count++,e.abrupt("return",{value:i,done:!1});case 18:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentPromise=this.nextState(this.currentPromise),e.abrupt("return",this.currentPromise);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(EM),GM=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.bufferSize=n,r.buffer=new wM(n),r}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Prefetch"},n.refill=function(){for(;!this.buffer.isFull();){var e=this.upstream.next();this.buffer.push(e)}},n.next=function(){return this.refill(),this.buffer.shift()},t}(EM),jM=function(e){function t(t,n,r){var a;return(a=e.call(this,t,n)||this).upstream=t,a.windowSize=n,a.upstreamExhausted=!1,a.random=dN(r||yg().toString()),a.lastRead=Promise.resolve({value:null,done:!1}),a}qm(t,e);var n=t.prototype;return n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.lastRead=this.lastRead.then((function(){return t.serialNext()})),e.abrupt("return",this.lastRead);case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.randomInt=function(e){return Math.floor(this.random()*e)},n.chooseIndex=function(){return this.randomInt(this.buffer.length())},n.serialNext=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.upstreamExhausted||this.refill();case 1:if(this.buffer.isEmpty()){e.next=14;break}return t=this.chooseIndex(),e.next=5,this.buffer.shuffleExcise(t);case 5:if(!(n=e.sent).done){e.next=10;break}this.upstreamExhausted=!0,e.next=12;break;case 10:return this.refill(),e.abrupt("return",n);case 12:e.next=1;break;case 14:return e.abrupt("return",{value:null,done:!0});case 15:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(GM),HM=function(){function e(){this.size=null}var t=e.prototype;return t.batch=function(e,t){void 0===t&&(t=!0);var n,r=this;return lv(e>0,(function(){return"batchSize needs to be positive, but it is\n      "+e})),n=this.size===1/0||null==this.size?this.size:t?Math.ceil(this.size/e):Math.floor(this.size/e),qM(Gm(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,r.iterator();case 2:return n.abrupt("return",n.sent.columnMajorBatch(e,t,KM));case 3:case"end":return n.stop()}}),n)}))),n)},t.concatenate=function(e){var t,n=this;return t=this.size===1/0||e.size===1/0?1/0:null!=this.size&&null!=e.size?this.size+e.size:null,qM(Gm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.iterator();case 2:return t.t0=t.sent,t.next=5,e.iterator();case 5:return t.t1=t.sent,t.abrupt("return",t.t0.concatenate.call(t.t0,t.t1));case 7:case"end":return t.stop()}}),t)}))),t)},t.filter=function(e){var t,n=this;return t=this.size===1/0?1/0:null,qM(Gm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.iterator();case 2:return t.abrupt("return",t.sent.filter((function(t){return dx((function(){return e(t)}))})));case 3:case"end":return t.stop()}}),t)}))),t)},t.forEachAsync=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.iterator();case 2:return e.abrupt("return",e.sent.forEachAsync(t));case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.map=function(e){var t=this;return qM(Gm(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.iterator();case 2:return n.abrupt("return",n.sent.map((function(t){return dx((function(){return e(t)}))})));case 3:case"end":return n.stop()}}),n)}))),this.size)},t.mapAsync=function(e){var t=this;return qM(Gm(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.iterator();case 2:return n.abrupt("return",n.sent.mapAsync(e));case 3:case"end":return n.stop()}}),n)}))),this.size)},t.prefetch=function(e){if(null==e)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var t=this;return qM(Gm(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.iterator();case 2:return n.abrupt("return",n.sent.prefetch(e));case 3:case"end":return n.stop()}}),n)}))),this.size)},t.repeat=function(e){var t,n=this;return t=null!=this.size&&e>0?this.size*e:0===e?0:null!=this.size&&(void 0===e||e<0)?1/0:null,qM(Gm(regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=IM(Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.iterator();case 2:return e.t0=e.sent,e.abrupt("return",{value:e.t0,done:!1});case 4:case"end":return e.stop()}}),e)})))),t.abrupt("return",SM(r.take(e)));case 2:case"end":return t.stop()}}),t)}))),t)},t.skip=function(e){var t,n=this;return t=null!=this.size&&e>=0&&this.size>=e?this.size-e:null!=this.size&&(this.size<e||void 0===e||e<0)?0:null,qM(Gm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.iterator();case 2:return t.abrupt("return",t.sent.skip(e));case 3:case"end":return t.stop()}}),t)}))),t)},t.shuffle=function(e,t,n){if(void 0===n&&(n=!0),null==e||e<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError("`Dataset.shuffle()` requires bufferSize to be specified.  If your data fits in main memory (for regular JS objects), and/or GPU memory (for `tf.Tensor`s), consider setting bufferSize to the dataset size ("+this.size+" elements)");var r=this,a=dN(t||yg().toString());return qM(Gm(regeneratorRuntime.mark((function t(){var i;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=a.int32(),n&&(i+=a.int32()),t.next=4,r.iterator();case 4:return t.abrupt("return",t.sent.shuffle(e,i.toString()));case 5:case"end":return t.stop()}}),t)}))),this.size)},t.take=function(e){var t,n=this;return t=null!=this.size&&this.size>e?e:null!=this.size&&this.size<=e?this.size:null,qM(Gm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.iterator();case 2:return t.abrupt("return",t.sent.take(e));case 3:case"end":return t.stop()}}),t)}))),t)},t.toArray=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.size!==1/0){e.next=2;break}throw new Error("Can not convert infinite data stream to array.");case 2:return e.next=4,this.iterator();case 4:return e.abrupt("return",e.sent.toArray());case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.toArrayForTest=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.size!==1/0){e.next=2;break}throw new Error("Can not convert infinite data stream to array.");case 2:return e.next=4,this.iterator();case 4:return e.abrupt("return",e.sent.toArrayForTest());case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}();function qM(e,t){return void 0===t&&(t=null),new(function(n){function r(){var e;return(e=n.apply(this,arguments)||this).size=t,e}return qm(r,n),r.prototype.iterator=function(){var t=Gm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e());case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),r}(HM))}function KM(e){return null===e?null:function(e){return null==e||(null===(t=e)||"object"!=typeof t&&"function"!=typeof t)||Array.isArray(e)||"object"==typeof e&&e instanceof Fg||Cv(e);var t}(e[0])?{value:function(e){if(0===e.length)throw new Error("Can't make a batch of zero elements.");return e[0]instanceof Fg?eI(e):ly(e)}(e),recurse:!1}:{value:null,recurse:!0}}HM.MAX_BUFFER_SIZE=1e4;var XM=function(e){function t(t){var n;return(n=e.call(this)||this).input=t,n}return qm(t,e),t.prototype.iterator=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.input.iterator();case 2:return t=e.sent,n=t.decodeUTF8(),r=n.split("\n").map((function(e){return e.endsWith("\r")&&(e=e.slice(0,-1)),e})),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(HM),YM=Symbol("out"),JM=Symbol("field"),ZM=Symbol("quote"),QM=Symbol("quoteafterquote"),$M=Symbol("quoteinquote"),eL=function(e){function t(t,n){var r;return(r=e.call(this)||this).input=t,r.hasHeader=!0,r.fullColumnNames=null,r.columnNamesValidated=!1,r.columnConfigs=null,r.configuredColumnsOnly=!1,r.delimiter=",",r.delimWhitespace=!1,r.base=new XM(t),n||(n={}),r.hasHeader=!1!==n.hasHeader,r.fullColumnNames=n.columnNames,r.columnConfigs=n.columnConfigs,r.configuredColumnsOnly=n.configuredColumnsOnly,n.delimWhitespace?(lv(null==n.delimiter,(function(){return"Delimiter should not be provided when delimWhitespace is true."})),r.delimWhitespace=!0,r.delimiter=" "):r.delimiter=n.delimiter?n.delimiter:",",r}qm(t,e);var n=t.prototype;return n.columnNames=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.columnNamesValidated){e.next=3;break}return e.next=3,this.setColumnNames();case 3:return e.abrupt("return",this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames);case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.setColumnNames=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a,i,o,s=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.maybeReadHeaderLine();case 2:if(t=e.sent,this.fullColumnNames||t){e.next=7;break}throw new Error("Column names must be provided if there is no header line.");case 7:this.fullColumnNames&&t&&lv(t.length===this.fullColumnNames.length,(function(){return"The length of provided columnNames ("+s.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+")."}));case 8:if(this.fullColumnNames||(this.fullColumnNames=t),n=this.fullColumnNames.reduce((function(e,t){return e[t]=e[t]+1||1,e}),{}),lv(0===(r=Object.keys(n).filter((function(e){return n[e]>1}))).length,(function(){return"Duplicate column names found: "+r.toString()})),!this.columnConfigs){e.next=22;break}a=0,i=Object.keys(this.columnConfigs);case 14:if(!(a<i.length)){e.next=22;break}if(o=i[a],-1!==this.fullColumnNames.indexOf(o)){e.next=19;break}throw new Error('The key "'+o+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");case 19:a++,e.next=14;break;case 22:this.columnNamesValidated=!0;case 23:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.maybeReadHeaderLine=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasHeader){e.next=14;break}return e.next=3,this.base.iterator();case 3:return t=e.sent,e.next=6,t.next();case 6:if(!(n=e.sent).done){e.next=9;break}throw new Error("No data was found for CSV parsing.");case 9:return r=n.value,a=this.parseRow(r,!1),e.abrupt("return",a);case 14:return e.abrupt("return",null);case 15:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.iterator=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.columnNamesValidated){e.next=3;break}return e.next=3,this.setColumnNames();case 3:return e.next=5,this.base.iterator();case 5:return t=e.sent,this.hasHeader&&(t=t.skip(1)),e.abrupt("return",t.map((function(e){return n.makeDataElement(e)})));case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.makeDataElement=function(e){for(var t=this.parseRow(e),n={},r={},a=0;a<this.fullColumnNames.length;a++){var i=this.fullColumnNames[a],o=this.columnConfigs?this.columnConfigs[i]:null;if(!this.configuredColumnsOnly||o){var s=t[a],u=null;if(""===s)if(o&&void 0!==o.default)u=o.default;else{if(o&&(o.required||o.isLabel))throw new Error("Required column "+i+" is empty in this line: "+e);u=void 0}else{var l=Number(s);if(isNaN(l))u=o&&"bool"===o.dtype?this.getBoolean(s):s;else if(o&&o.dtype)switch(o.dtype){case"float32":u=l;break;case"int32":u=Math.floor(l);break;case"bool":u=this.getBoolean(s);break;default:u=l}else u=l}o&&o.isLabel?r[i]=u:n[i]=u}}return 0===Object.keys(r).length?n:{xs:n,ys:r}},n.getBoolean=function(e){return"1"===e||"true"===e.toLowerCase()?1:0},n.parseRow=function(e,t){void 0===t&&(t=!0);for(var n=[],r=0,a=e.length,i=YM,o=0;o<a;o++)switch(i){case YM:switch(e.charAt(o)){case'"':r=o+1,i=ZM;break;case this.delimiter:if(r=o+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),i=YM;break;default:i=JM,r=o}break;case JM:switch(e.charAt(o)){case this.delimiter:n.push(e.substring(r,o)),i=YM,r=o+1}break;case ZM:switch(e.charAt(o)){case'"':i=QM}break;case QM:switch(e.charAt(o)){case this.delimiter:n.push(e.substring(r,o-1)),i=YM,r=o+1;break;case'"':i=ZM;break;default:i=$M}break;case $M:switch(e.charAt(o)){case'"':i=ZM}}if(i===QM?n.push(e.substring(r,a-1)):n.push(e.substring(r)),t&&n.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have "+this.fullColumnNames.length+" elements in a row, but got "+n);return n},t}(HM),tL=function(e){function t(t){var n;(n=e.call(this)||this).microphoneConfig=t,n.isClosed=!1,n.fftSize=t.fftSize||1024;var r=Math.log2(n.fftSize);if(n.fftSize<0||r<4||r>14||!Number.isInteger(r))throw new Error("Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got "+n.fftSize);if(n.numFrames=t.numFramesPerSpectrogram||43,n.sampleRateHz=t.sampleRateHz,n.columnTruncateLength=t.columnTruncateLength||n.fftSize,n.audioTrackConstraints=t.audioTrackConstraints,n.smoothingTimeConstant=t.smoothingTimeConstant||0,n.includeSpectrogram=!1!==t.includeSpectrogram,n.includeWaveform=!0===t.includeWaveform,!n.includeSpectrogram&&!n.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return n}qm(t,e);var n=t.prototype;return n.summary=function(){return"microphone"},t.create=function(){var e=Gm(regeneratorRuntime.mark((function e(n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n={}),!Xv().get("IS_NODE")){e.next=3;break}throw new Error("microphone API is only supported in browser environment.");case 3:return r=new t(n),e.next=6,r.start();case 6:return e.abrupt("return",r);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.start=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1});case 3:this.stream=e.sent,e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(0),new Error("Error thrown while initializing video stream: "+e.t0.message);case 9:if(this.stream){e.next=11;break}throw new Error("Could not obtain audio from microphone.");case 11:if(t=window.AudioContext||window.webkitAudioContext,this.audioContext=new t,this.sampleRateHz){e.next=17;break}this.sampleRateHz=this.audioContext.sampleRate,e.next=19;break;case 17:if(this.audioContext.sampleRate===this.sampleRateHz){e.next=19;break}throw new Error("Mismatch in sampling rate: Expected: "+this.sampleRateHz+"; Actual: "+this.audioContext.sampleRate);case 19:return n=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,n.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),e.abrupt("return");case 27:case"end":return e.stop()}}),e,this,[[0,6]])})));return function(){return e.apply(this,arguments)}}(),n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isClosed){e.next=2;break}return e.abrupt("return",{value:null,done:!0});case 2:return e.next=4,this.getAudioData();case 4:return r=e.sent,this.includeSpectrogram&&(a=this.flattenQueue(r.freqDataQueue),t=this.getTensorFromAudioDataArray(a,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(r.timeDataQueue),n=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),e.abrupt("return",{value:{spectrogram:t,waveform:n},done:!1});case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.capture=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.next();case 2:return e.abrupt("return",e.sent.value);case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.getAudioData=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],n=[],r=0,e.abrupt("return",new Promise((function(e){var i=setInterval((function(){a.includeSpectrogram&&(a.analyser.getFloatFrequencyData(a.freqData),a.freqData[0]===-1/0&&e({freqDataQueue:t,timeDataQueue:n}),t.push(a.freqData.slice(0,a.columnTruncateLength))),a.includeWaveform&&(a.analyser.getFloatTimeDomainData(a.timeData),n.push(a.timeData.slice())),++r===a.numFrames&&(clearInterval(i),e({freqDataQueue:t,timeDataQueue:n}))}),a.fftSize/a.sampleRateHz*1e3)})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),n.stop=function(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop())},n.toArray=function(){throw new Error("Can not convert infinite audio stream to array.")},n.getSampleRate=function(){return this.sampleRateHz},n.flattenQueue=function(e){var t=e[0].length,n=new Float32Array(e.length*t);return e.forEach((function(e,r){return n.set(e,r*t)})),n},n.getTensorFromAudioDataArray=function(e,t){var n=new Float32Array(fv(t));return n.set(e,n.length-e.length),ly(n,t)},t}(EM),nL=function(e){function t(t,n){var r;if((r=e.call(this)||this).webcamVideoElement=t,r.webcamConfig=n,r.isClosed=!0,r.resize=!1,r.needToResize())if(r.resize=!0,r.cropSize=[r.webcamConfig.resizeHeight,r.webcamConfig.resizeWidth],r.cropBoxInd=aI([0],"int32"),r.webcamConfig.centerCrop){var a=1*r.webcamConfig.resizeWidth/r.webcamVideoElement.width,i=1*r.webcamConfig.resizeHeight/r.webcamVideoElement.height,o=(1-a)/2,s=(1-i)/2,u=o+a,l=i+s;r.cropBox=iI([s,o,l,u],[1,4])}else r.cropBox=iI([0,0,1,1],[1,4]);return r}qm(t,e);var n=t.prototype;return n.summary=function(){return"webcam"},t.create=function(){var e=Gm(regeneratorRuntime.mark((function e(n,r){var a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===r&&(r={}),!Xv().get("IS_NODE")){e.next=3;break}throw new Error("tf.data.webcam is only supported in browser environment.");case 3:if(n){e.next=9;break}if(n=document.createElement("video"),r.resizeWidth&&r.resizeHeight){e.next=7;break}throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");case 7:n.width=r.resizeWidth,n.height=r.resizeHeight;case 9:return a=new t(n,r),e.next=12,a.start();case 12:return e.abrupt("return",a);case 13:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),n.start=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.webcamConfig.facingMode&&lv("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,(function(){return"Invalid webcam facing mode: "+t.webcamConfig.facingMode+". Please provide 'user' or 'environment'"})),e.prev=1,e.next=4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}});case 4:this.stream=e.sent,e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(1),e.t0.message="Error thrown while initializing video stream: "+e.t0.message,e.t0;case 11:if(this.stream){e.next=13;break}throw new Error("Could not obtain video from webcam.");case 13:try{this.webcamVideoElement.srcObject=this.stream}catch(e){console.log(e),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream)}return this.webcamVideoElement.play(),this.isClosed=!1,e.abrupt("return",new Promise((function(e){t.webcamVideoElement.onloadedmetadata=function(){e()}})));case 17:case"end":return e.stop()}}),e,this,[[1,7]])})));return function(){return e.apply(this,arguments)}}(),n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isClosed){e.next=2;break}return e.abrupt("return",{value:null,done:!0});case 2:e.prev=2,t=Db(this.webcamVideoElement),e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(2),new Error("Error thrown converting video to pixels: "+JSON.stringify(e.t0));case 9:if(!this.resize){e.next=22;break}return e.prev=10,e.abrupt("return",{value:this.cropAndResizeFrame(t),done:!1});case 14:throw e.prev=14,e.t1=e.catch(10),new Error("Error thrown cropping the video: "+e.t1.message);case 17:return e.prev=17,t.dispose(),e.finish(17);case 20:e.next=23;break;case 22:return e.abrupt("return",{value:t,done:!1});case 23:case"end":return e.stop()}}),e,this,[[2,6],[10,14,17,20]])})));return function(){return e.apply(this,arguments)}}(),n.needToResize=function(){return!(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight)},n.cropAndResizeFrame=function(e){var t=this;return dx((function(){var n,r=e.toFloat().expandDims(0),a=(n=GS.cropAndResize(r,t.cropBox,t.cropBoxInd,t.cropSize,"bilinear")).shape;return n.reshape(a.slice(1))}))},n.capture=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.next();case 2:return e.abrupt("return",e.sent.value);case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.stop=function(){this.stream.getTracks().forEach((function(e){return e.stop()}));try{this.webcamVideoElement.srcObject=null}catch(e){console.log(e),this.webcamVideoElement.src=null}this.isClosed=!0},n.toArray=function(){throw new Error("Can not convert infinite video stream to array.")},t}(EM),rL=function(){},aL=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.split=function(e){return new iL(this,e)},t}(EM),iL=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.impl=new oL(t,n),r}qm(t,e);var n=t.prototype;return n.summary=function(){return this.impl.summary()},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.impl.next());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(aL),oL=function(e){function t(t,n){var r;return(r=e.call(this)||this).upstream=t,r.separator=n,r.carryover="",r}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')"},n.pump=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.upstream.next();case 2:if(!(t=e.sent).done){e.next=9;break}if(""!==this.carryover){e.next=6;break}return e.abrupt("return",!1);case 6:return this.outputQueue.push(this.carryover),this.carryover="",e.abrupt("return",!0);case 9:for((n=t.value.split(this.separator))[0]=this.carryover+n[0],r=tv(n.slice(0,-1));!(a=r()).done;)i=a.value,this.outputQueue.push(i);return this.carryover=n[n.length-1],e.abrupt("return",!0);case 14:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(BM),sL=function(e){function t(){return e.apply(this,arguments)||this}return qm(t,e),t.prototype.decodeUTF8=function(){return new uL(this)},t}(EM),uL=function(e){function t(t){var n;return(n=e.call(this)||this).upstream=t,n.impl=new lL(t),n}qm(t,e);var n=t.prototype;return n.summary=function(){return this.impl.summary()},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.impl.next());case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(aL),lL=function(e){function t(t){var n;if((n=e.call(this)||this).upstream=t,Xv().get("IS_BROWSER"))n.decoder=new TextDecoder("utf-8");else{var r=require("string_decoder").StringDecoder;n.decoder=new r("utf8")}return n}qm(t,e);var n=t.prototype;return n.summary=function(){return this.upstream.summary()+" -> Utf8"},n.pump=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.upstream.next();case 2:if(!(t=e.sent).done){e.next=7;break}return e.abrupt("return",!1);case 7:n=t.value;case 8:return r=Xv().get("IS_BROWSER")?this.decoder.decode(n,{stream:!0}):this.decoder.write(Buffer.from(n.buffer)),this.outputQueue.push(r),e.abrupt("return",!0);case 11:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(BM),cL=function(e){function t(t,n){var r;return void 0===n&&(n={}),(r=e.call(this)||this).file=t,r.options=n,lv(t instanceof Uint8Array||!!Xv().get("IS_BROWSER")&&(t instanceof File||t instanceof Blob),(function(){return"FileChunkIterator only supports File, Blob and Uint8Array right now."})),r.offset=n.offset||0,r.chunkSize=n.chunkSize||1048576,r}qm(t,e);var n=t.prototype;return n.summary=function(){return"FileChunks "+this.file},n.next=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size))){e.next=2;break}return e.abrupt("return",{value:null,done:!0});case 2:return t=new Promise((function(e,t){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)e(new Uint8Array(n.file.slice(n.offset,r)));else{var a=new FileReader;a.onload=function(n){var r=a.result;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!(r instanceof Uint8Array))return t(new TypeError("FileReader returned unknown type."));e(r)},a.onabort=function(e){return t(new Error("Aborted"))},a.onerror=function(e){return t(new Error(e.type))};var i=n.file.slice(n.offset,r);a.readAsArrayBuffer(i)}n.offset=r})),e.next=5,t;case 5:return e.t0=e.sent,e.abrupt("return",{value:e.t0,done:!1});case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(sL);function pL(e,t){return hL.apply(this,arguments)}function hL(){return(hL=Gm(regeneratorRuntime.mark((function e(t,n){var r,a,i,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===n&&(n={}),"string"==typeof t?r=t:(r=t.url,a=fL(t)),e.next=4,bg(r,a);case 4:if(!(i=e.sent).ok){e.next=14;break}return e.t0=Uint8Array,e.next=9,i.arrayBuffer();case 9:return e.t1=e.sent,o=new e.t0(e.t1),e.abrupt("return",new cL(o,n));case 14:throw new Error(i.statusText);case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var fL=function(e){return{method:e.method,headers:e.headers,body:e.body,mode:e.mode,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,integrity:e.integrity}};function dL(e){return"string"==typeof e&&"file://"===e.substr(0,7)}var mL=function(e){function t(t,n){var r;return void 0===n&&(n={}),(r=e.call(this)||this).input=t,r.options=n,r}return qm(t,e),t.prototype.iterator=function(){var e=Gm(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return dL(this.input)&&Xv().get("IS_NODE")&&(t=require("fs"),this.input=t.readFileSync(this.input.substr(7))),e.abrupt("return",new cL(this.input,this.options));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(rL),vL=function(e){function t(t,n){var r;return void 0===n&&(n={}),(r=e.call(this)||this).url=t,r.fileOptions=n,r}return qm(t,e),t.prototype.iterator=function(){var e=Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!dL(this.url)){e.next=4;break}return e.abrupt("return",new mL(this.url,this.fileOptions).iterator());case 4:return e.abrupt("return",pL(this.url,this.fileOptions));case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(rL);function gL(){return(gL=Gm(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",nL.create(t,n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yL(){return(yL=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",tL.create(t));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var bL={__proto__:null,array:function(e){return qM(Gm(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",NM(e));case 1:case"end":return t.stop()}}),t)}))),e.length)},Dataset:HM,zip:function(e){if(!yM(e))throw new Error("The argument to zip() must be an object or array.");var t;if(Array.isArray(e))for(var n=0;n<e.length;n++)t=null==t?e[n].size:Math.min(t,e[n].size);else if(e instanceof Object)for(var r in e)t=null==t?e[r].size:Math.min(t,e[r].size);return qM(Gm(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,vM(e,(function(e){if(e instanceof HM)return{value:e.iterator(),recurse:!1};if(yM(e))return{value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.")}));case 2:return n=t.sent,t.abrupt("return",TM(n,CM.SHORTEST));case 4:case"end":return t.stop()}}),t)}))),t)},CSVDataset:eL,TextLineDataset:XM,csv:function(e,t){return void 0===t&&(t={}),new eL(new vL(e),t)},func:function(e){var t=IM(e);return qM(Gm(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t);case 1:case"end":return e.stop()}}),e)}))))},generator:function(e){return qM(Gm(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e();case 2:return n=t.sent,t.abrupt("return",IM((function(){return n.next()})));case 4:case"end":return t.stop()}}),t)}))))},microphone:function(e){return yL.apply(this,arguments)},webcam:function(e,t){return gL.apply(this,arguments)},FileDataSource:mL,URLDataSource:vL,version_data:"2.8.1"};function xL(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){null!=e&&lv("complex64"!==e.dtype,(function(){return t+" does not support complex64 tensors in the CPU backend."}))}))}var wL=hI,kL=function(e){function t(){var t;return(t=e.call(this)||this).blockSize=48,t.firstUse=!0,t.data=new nv(Qm(t),hx()),t}qm(t,e);var n=t.prototype;return n.write=function(e,t,n){this.firstUse&&(this.firstUse=!1,Xv().get("IS_NODE")&&dT("\n============================\nHi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.\n============================"));var r={};return this.data.set(r,{values:e,dtype:n,refCount:1}),r},n.makeTensorInfo=function(e,t,n){var r;if("string"===t&&null!=n&&n.length>0&&Av(n[0])){var a=n.map((function(e){return xg(e)}));r=this.write(a,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}},n.incRef=function(e){this.data.get(e).refCount++},n.decRef=function(e){this.data.has(e)&&this.data.get(e).refCount--},n.move=function(e,t,n,r){this.data.set(e,{values:t,dtype:r,refCount:1})},n.numDataIds=function(){return this.data.numDataIds()},n.read=function(){var e=Gm(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readSync(t));case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.readSync=function(e){var t=this.data.get(e),n=t.dtype,r=t.complexTensorInfos;return"complex64"===n?mT(this.readSync(r.real.dataId),this.readSync(r.imag.dataId)):this.data.get(e).values},n.bufferSync=function(e){var t=this.readSync(e.dataId),n=t;if("string"===e.dtype)try{n=t.map((function(e){return wg(e)}))}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return nb(e.shape,e.dtype,n)},n.makeOutput=function(e,t,n){var r=this.write(e,t,n);return hx().makeTensorFromDataId(r,t,n,this)},n.disposeData=function(e){if(this.data.has(e)){var t=this.data.get(e).complexTensorInfos;null!=t&&(this.disposeData(t.real.dataId),this.disposeData(t.imag.dataId)),this.data.delete(e)}},n.disposeIntermediateTensorInfo=function(e){var t=e.dataId;if(this.data.has(t)){var n=this.data.get(t);n.refCount--,n.refCount<1&&this.disposeData(t)}},n.time=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=yg(),t(),r=yg()-n,e.abrupt("return",{kernelMs:r});case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),n.memory=function(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}},n.where=function(e){xL([e],"where");var t=this.readSync(e.dataId);return wL(e.shape,t)},n.dispose=function(){},n.floatPrecision=function(){return 32},n.epsilon=function(){return e.prototype.epsilon.call(this)},t}(rv);function NL(e){for(var t=new Float32Array(e.length),n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t}var IL={kernelName:"Abs",backendName:"cpu",kernelFunc:function(e){var t=e.inputs.x,n=e.backend;xL(t,"abs");var r=new Float32Array(fv(t.shape));return r=NL(n.data.get(t.dataId).values),n.makeOutput(r,t.shape,"float32")}};function SL(e){return function(t,n,r,a,i){var o=Ow(t,n),s=o.length,u=Lv(o),l=kv(i,fv(o)),c=t.length,p=n.length,h=Lv(t),f=Lv(n),d=Fw(t,o),m=Fw(n,o);if(d.length+m.length===0)for(var v=0;v<l.length;++v)l[v]=e(r[v%r.length],a[v%a.length]);else for(var g=function(t){var n=Gv(t,s,u),i=n.slice(-c);d.forEach((function(e){return i[e]=0}));var o=Uv(i,c,h),v=n.slice(-p);m.forEach((function(e){return v[e]=0}));var g=Uv(v,p,f);l[t]=e(r[o],a[g])},y=0;y<l.length;++y)g(y);return[l,o]}}function TL(e){var t=e.inputs,n=e.backend,r=t.real,a=t.imag,i=n.data.get(r.dataId).values,o=n.data.get(a.dataId).values,s=n.makeTensorInfo(r.shape,"complex64");return n.data.get(s.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",i),imag:n.makeTensorInfo(a.shape,"float32",o)},s}var CL={kernelName:"Complex",backendName:"cpu",kernelFunc:TL};function EL(e,t,n){if(void 0===n&&(n="float32"),"complex64"===n)return TL({inputs:{real:EL(e,t,"float32"),imag:EL(e,t,"float32")},backend:e});var r=Bv(fv(t),n);return e.makeTensorInfo(t,n,r)}function RL(e){var t=e.inputs,n=e.backend,r=t.x;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}var AL={kernelName:"Identity",backendName:"cpu",kernelFunc:RL};function DL(e){var t=e.inputs,n=e.backend,r=t.input,a=n.data.get(r.dataId).complexTensorInfos.real,i=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,i)}var FL={kernelName:"Real",backendName:"cpu",kernelFunc:DL};function _L(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.dtype;if("complex64"===i){if("complex64"===a.dtype)return RL({inputs:{x:a},backend:n});var o=EL(n,a.shape,a.dtype),s=_L({inputs:{x:a},backend:n,attrs:{dtype:"float32"}}),u=TL({inputs:{real:s,imag:o},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),u}if("complex64"===a.dtype){var l=DL({inputs:{input:a},backend:n}),c=_L({inputs:{x:l},backend:n,attrs:{dtype:i}});return n.disposeIntermediateTensorInfo(l),c}if(!Tv(a.dtype,i)){var p=RL({inputs:{x:a},backend:n});return{dataId:p.dataId,shape:p.shape,dtype:i}}if("int32"===i){var h=n.data.get(a.dataId).values,f=Int32Array.from(h);return n.makeTensorInfo(a.shape,"int32",f)}if("bool"===i){var d=n.data.get(a.dataId).values,m=gg([0],a.dtype),v=SL((function(e,t){return e!==t?1:0}))(a.shape,[],d,m,"bool"),g=v[0],y=v[1];return n.makeTensorInfo(y,"bool",g)}throw new Error("Error in Cast: failed to cast "+a.dtype+" to "+i)}var OL={kernelName:"Cast",backendName:"cpu",kernelFunc:_L};function ML(e,t,n,r){return null==n?function(n){var a=n.inputs,i=n.backend,o=a.a,s=a.b,u=i;xL([o,s],e);var l=u.data.get(o.dataId).values,c=u.data.get(s.dataId).values,p=r||o.dtype,h=t(o.shape,s.shape,l,c,p),f=h[0],d=h[1];return u.makeTensorInfo(d,p,f)}:function(e){var a=e.inputs,i=e.backend,o=a.a,s=a.b,u=i;if("complex64"===o.dtype||"complex64"===s.dtype){var l=_L({inputs:{x:o},backend:u,attrs:{dtype:"complex64"}}),c=u.data.get(l.dataId),p=c.complexTensorInfos.real,h=c.complexTensorInfos.imag,f=u.data.get(p.dataId).values,d=u.data.get(h.dataId).values,m=_L({inputs:{x:s},backend:u,attrs:{dtype:"complex64"}}),v=u.data.get(m.dataId),g=v.complexTensorInfos.real,y=v.complexTensorInfos.imag,b=u.data.get(g.dataId).values,x=u.data.get(y.dataId).values,w=n(o.shape,s.shape,f,d,b,x),k=w[0],N=w[1],I=w[2],S=u.makeTensorInfo(I,"float32",k),T=u.makeTensorInfo(I,"float32",N),C=TL({inputs:{real:S,imag:T},backend:u});return u.disposeIntermediateTensorInfo(l),u.disposeIntermediateTensorInfo(m),u.disposeIntermediateTensorInfo(S),u.disposeIntermediateTensorInfo(T),C}var E=u.data.get(o.dataId).values,R=u.data.get(s.dataId).values,A=r||o.dtype,D=t(o.shape,s.shape,E,R,A),F=D[0],_=D[1];return u.makeTensorInfo(_,A,F)}}function LL(e){return function(t,n,r,a,i,o){var s=Ow(t,n),u=fv(s),l=s.length,c=Lv(s),p=kv("float32",u),h=kv("float32",u),f=Fw(t,s),d=Fw(n,s),m=mT(r,a),v=mT(i,o),g=t.length,y=Lv(t),b=n.length,x=Lv(n);if(f.length+d.length===0)for(var w=0;w<p.length;w++){var k=w%m.length,N=w%v.length,I=e(m[2*k],m[2*k+1],v[2*N],v[2*N+1]);p[w]=I.real,h[w]=I.imag}else for(var S=function(t){var n=Gv(t,l,c),r=n.slice(-g);f.forEach((function(e){return r[e]=0}));var a=Uv(r,g,y),i=n.slice(-b);d.forEach((function(e){return i[e]=0}));var o=Uv(i,b,x),s=e(m[2*a],m[2*a+1],v[2*o],v[2*o+1]);p[t]=s.real,h[t]=s.imag},T=0;T<p.length;T++)S(T);return[p,h,s]}}var zL=SL((function(e,t){return e+t})),PL=LL((function(e,t,n,r){return{real:e+n,imag:t+r}})),BL=ML(Zv,zL,PL),WL={kernelName:Zv,backendName:"cpu",kernelFunc:BL};function VL(e,t,n,r,a){for(var i=fv(r),o=Bv(a,n),s=0;s<e.length;s++){var u=e[s];if(u<0)throw new Error("Input x must be non-negative!");u>=a||(o[u]+=i>0?t[s]:1)}return o}function UL(e,t,n,r){void 0===r&&(r=!1);for(var a=e.shape[0],i=e.shape[1],o=nb([a,n],t.dtype),s=0;s<a;s++)for(var u=0;u<i;u++){var l=e.get(s,u);if(l<0)throw new Error("Input x must be non-negative!");l>=n||(r?o.set(1,s,l):t.size>0?o.set(o.get(s,l)+t.get(s,u),s,l):o.set(o.get(s,l)+1,s,l))}return o}function GL(e){return function(t,n,r){for(var a=kv(n,t.length),i=0;i<t.length;++i)a[i]=e(t[i],r);return a}}function jL(e,t,n){return function(r){var a=r.inputs,i=r.attrs,o=r.backend,s=a.x;if(xL(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");for(var u=o,l=u.data.get(s.dataId).values,c=fv(s.shape),p=n||s.dtype,h=Nv(p,c),f=0;f<c;++f)h[f]=t(l[f],i);return u.makeTensorInfo(s.shape,p,h)}}function HL(e,t,n){return function(r){var a=r.inputs,i=r.attrs,o=r.backend,s=a.x;if(xL(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");var u=o,l=u.data.get(s.dataId).values,c=n||s.dtype,p=t(l,c,i);return u.makeTensorInfo(s.shape,c,p)}}var qL=GL((function(e){return Math.ceil(e)})),KL={kernelName:"Ceil",backendName:"cpu",kernelFunc:HL("Ceil",qL)},XL=GL((function(e){return Math.exp(e)})),YL=HL(tg,XL),JL={kernelName:tg,backendName:"cpu",kernelFunc:YL},ZL=GL((function(e){return Math.expm1(e)})),QL={kernelName:"Expm1",backendName:"cpu",kernelFunc:HL("Expm1",ZL)},$L=GL((function(e){return Math.floor(e)})),ez={kernelName:"Floor",backendName:"cpu",kernelFunc:HL("Floor",$L)};function tz(e,t,n){for(var r=nb(n,e.dtype),a=0;a<r.size;++a){var i=r.indexToLoc(a).slice(),o=i[0],s=i[2],u=t.locToIndex([o,s]);i[2]=t.values[u];var l=e.locToIndex(i);r.values[a]=e.values[l]}return r}var nz=SL((function(e,t){return e>t?1:0})),rz={kernelName:"Greater",backendName:"cpu",kernelFunc:ML("Greater",nz,null,"bool")},az=SL((function(e,t){return e<t?1:0})),iz={kernelName:"Less",backendName:"cpu",kernelFunc:ML("Less",az,null,"bool")};function oz(e,t,n){var r=(t-e)/(n-1),a=Bv(n,"float32");a[0]=e;for(var i=1;i<a.length;i++)a[i]=a[i-1]+r;return a}var sz=GL((function(e){return Math.log(e)})),uz=HL(ng,sz),lz={kernelName:ng,backendName:"cpu",kernelFunc:uz};function cz(e,t,n,r){for(var a=kv(r,fv(n)),i=0;i<a.length;++i){for(var o=i*t,s=e[o],u=0;u<t;++u){var l=e[o+u];l>s&&(s=l)}a[i]=s}return a}var pz=SL((function(e,t){return Math.max(e,t)})),hz={kernelName:"Maximum",backendName:"cpu",kernelFunc:ML("Maximum",pz)},fz=SL((function(e,t){return Math.min(e,t)})),dz={kernelName:"Minimum",backendName:"cpu",kernelFunc:ML("Minimum",fz)},mz=SL((function(e,t){return e*t})),vz=LL((function(e,t,n,r){return{real:e*n-t*r,imag:e*r+t*n}})),gz=ML("Multiply",mz,vz),yz={kernelName:"Multiply",backendName:"cpu",kernelFunc:gz};function bz(e,t,n){var r=vg(-1,n);return mz([],t,r,e,n)}var xz={kernelName:"Neg",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x;xL(r,"neg");var a=bz(n.data.get(r.dataId).values,r.shape,r.dtype),i=a[0],o=a[1];return n.makeTensorInfo(o,r.dtype,i)}},wz={kernelName:"NotEqual",backendName:"cpu",kernelFunc:ML("NotEqual",SL((function(e,t){return e!==t?1:0})),null,"bool")};function kz(e,t,n,r,a){for(var i=t.length,o=fv(t),s=Lv(t),u=Lv(a),l=kv(n,fv(a)),c=0;c<o;++c){for(var p=Gv(c,i,s),h=new Array(p.length),f=0;f<h.length;f++)h[f]=p[r[f]];l[Uv(h,i,u)]=e[c]}return l}function Nz(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,i=n.perm;xL(a,"transpose");for(var o=a.shape.length,s=new Array(o),u=0;u<s.length;u++)s[u]=a.shape[i[u]];var l=kz(r.data.get(a.dataId).values,a.shape,a.dtype,i,s);return{dataId:r.write(l,s,a.dtype),shape:s,dtype:a.dtype}}var Iz={kernelName:"Transpose",backendName:"cpu",kernelFunc:Nz};function Sz(e,t,n,r){for(var a=wk(e,r),i=a[0],o=a[1],s=Wg(t,"int32"),u=Bv(fv(i),s),l=fv(o),c=0;c<u.length;++c){for(var p=c*l,h=1,f=0;f<l;++f)h*=n[p+f];u[c]=h}return{outVals:u,outShape:i,outDtype:s}}var Tz={kernelName:"Prod",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims;xL(a,"prod");var s=a.shape.length,u=xv(i,a.shape),l=Ik(u,s),c=u,p=a,h=[];null!=l&&(p=Nz({inputs:{x:a},backend:n,attrs:{perm:l}}),h.push(p),c=Tk(c.length,s));var f=n.data.get(p.dataId).values,d=Sz(p.shape,p.dtype,f,c),m=d.outVals,v=d.outShape,g=d.outDtype,y=v;return o&&(y=kk(v,u)),h.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.makeTensorInfo(y,g,m)}};function Cz(e,t,n,r){if(e===t||e<t&&n<0||t<e&&n>1)return Bv(0,r);var a=Bv(Math.abs(Math.ceil((t-e)/n)),r);t<e&&1===n&&(n=-1),a[0]=e;for(var i=1;i<a.length;i++)a[i]=a[i-1]+n;return a}var Ez=GL((function(e){return 1/Math.sqrt(e)})),Rz={kernelName:"Rsqrt",backendName:"cpu",kernelFunc:HL("Rsqrt",Ez)};function Az(e,t,n,r,a){var i=Zb(r,t,n),o=fv(n),s=Lv(r);if(i){var u=Qb(t,s);return"string"===a?e.slice(u,u+o):e.subarray(u,u+o)}for(var l=nb(r,a,"string"===a?CT(e):e),c=nb(n,a),p=0;p<c.size;++p){var h=c.indexToLoc(p),f=h.map((function(e,n){return e+t[n]}));c.set.apply(c,[l.get.apply(l,f)].concat(h))}return"string"===a?ET(c.values):c.values}function Dz(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.begin,o=r.size;xL(a,"slice");var s=$b(a,i,o),u=s[0],l=s[1];Bb(a,u,l);var c=Az(n.data.get(a.dataId).values,u,l,a.shape,a.dtype);return n.makeTensorInfo(l,a.dtype,c)}var Fz={kernelName:"Slice",backendName:"cpu",kernelFunc:Dz},_z={kernelName:"SquaredDifference",backendName:"cpu",kernelFunc:ML("SquaredDifference",SL((function(e,t){var n=e-t;return n*n})))};function Oz(e,t,n,r){for(var a=nb(e,t.dtype),i=0;i<a.size;i++){for(var o=a.indexToLoc(i),s=new Array(o.length),u=0;u<s.length;u++)s[u]=o[u]*n[u]+r[u];a.set.apply(a,[t.get.apply(t,s)].concat(o))}return a}var Mz=SL((function(e,t){return e-t})),Lz=LL((function(e,t,n,r){return{real:e-n,imag:t-r}})),zz=ML(og,Mz,Lz),Pz={kernelName:og,backendName:"cpu",kernelFunc:zz};function Bz(e,t){for(var n=new Array(e.rank),r=0;r<n.length;r++)n[r]=e.shape[r]*t[r];for(var a=nb(n,e.dtype),i=0;i<a.values.length;++i){for(var o=a.indexToLoc(i),s=new Array(e.rank),u=0;u<s.length;u++)s[u]=o[u]%e.shape[u];var l=e.locToIndex(s);a.values[i]=e.values[l]}return a}function Wz(e,t,n,r,a){for(var i=t[t.length-1],o=e.length/i,s=i,u=kv(n,o*r),l=kv("int32",o*r),c=0;c<o;c++){for(var p=c*s,h=e.subarray(p,p+s),f=[],d=0;d<h.length;d++)f.push({value:h[d],index:d});f.sort((function(e,t){return t.value-e.value}));for(var m=c*r,v=u.subarray(m,m+r),g=l.subarray(m,m+r),y=0;y<r;y++)v[y]=f[y].value,g[y]=f[y].index}var b=t.slice();return b[b.length-1]=r,[nb(b,n,u),nb(b,"int32",l)]}function Vz(e,t,n,r){for(var a=xv(t,n)[0],i=[1,n[0],1],o=0;o<a;o++)i[0]*=n[o];i[1]=n[a];for(var s=a+1;s<n.length;s++)i[2]*=n[s];for(var u={},l=new Int32Array(n[a]),c=new Rg(i,r,e),p=[],h=1===i[0]&&1===i[2],f=0;f<n[a];f++){var d=void 0;if(h)d=e[f].toString();else{for(var m=[],v=0;v<i[0];v++)for(var g=0;g<i[2];g++)m.push(c.get(v,f,g));d=m.join(",")}if(void 0!==u[d])l[f]=u[d];else{var y=Object.keys(u).length;u[d]=y,l[f]=y,p.push(f)}}var b=i.slice();b[1]=Object.keys(u).length;var x=new Rg(b,r);p.forEach((function(e,t){for(var n=0;n<i[0];n++)for(var r=0;r<i[2];r++)x.set(c.get(n,e,r),n,t,r)}));var w=n.slice();return w[a]=b[1],{outputValues:x.values,outputShape:w,indices:l}}yx("cpu",(function(){return new kL}),1);var Uz=jL($v,(function(e){return e>=0?e:Math.exp(e)-1})),Gz={kernelName:$v,backendName:"cpu",kernelFunc:Uz};function jz(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.alpha;xL([a],"leakyRelu");for(var o=fv(a.shape),s=n.data.get(a.dataId).values,u=kv("float32",o),l=0;l<s.length;l++)u[l]=s[l]<0?i*s[l]:s[l];return n.makeTensorInfo(a.shape,"float32",u)}var Hz={kernelName:"LeakyRelu",backendName:"cpu",kernelFunc:jz},qz=SL((function(e,t){return e<0?t*e:e}));function Kz(e){var t=e.inputs,n=e.backend,r=t.x,a=t.alpha;xL([r,a],"prelu");var i=n.data.get(r.dataId).values,o=n.data.get(a.dataId).values,s=qz(r.shape,a.shape,i,o,r.dtype),u=s[0],l=s[1];return n.makeTensorInfo(l,r.dtype,u)}var Xz={kernelName:"Prelu",backendName:"cpu",kernelFunc:Kz},Yz=jL("Relu",(function(e){return Math.max(0,e)})),Jz={kernelName:"Relu",backendName:"cpu",kernelFunc:Yz},Zz=jL("Relu6",(function(e){return Math.min(Math.max(0,e),6)})),Qz={kernelName:"Relu6",backendName:"cpu",kernelFunc:Zz};function $z(e,t,n,r,a){if("linear"===n)return RL({inputs:{x:t},backend:e});if("relu"===n)return Yz({inputs:{x:t},backend:e});if("elu"===n)return Uz({inputs:{x:t},backend:e});if("relu6"===n)return Zz({inputs:{x:t},backend:e});if("prelu"===n)return Kz({inputs:{x:t,alpha:r},backend:e});if("leakyrelu"===n)return jz({inputs:{x:t},backend:e,attrs:{alpha:a}});throw new Error("Activation "+n+" has not been implemented for the CPU backend.")}function eP(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.shape,o=fv(a.shape),s=bv(i,o),u=fv(s);lv(o===u,(function(){return"The new shape ("+s+") has "+u+" elements and the old shape ("+a.shape+") has "+o+" elements. The new shape and old shape must have the same number of elements."})),n.incRef(a.dataId);var l=n.data.get(a.dataId);if(null!=l.complexTensorInfos){var c=l.complexTensorInfos.real,p=l.complexTensorInfos.imag;c.shape=s,p.shape=s}return{dataId:a.dataId,shape:s,dtype:a.dtype}}var tP={kernelName:"Reshape",backendName:"cpu",kernelFunc:eP};function nP(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.a,i=t.b,o=r.transposeA,s=r.transposeB;xL([a,i],"matMul");var u=a.shape.length,l=i.shape.length,c=o?a.shape[u-2]:a.shape[u-1],p=s?i.shape[l-1]:i.shape[l-2],h=o?a.shape[u-1]:a.shape[u-2],f=s?i.shape[l-2]:i.shape[l-1],d=a.shape.slice(0,-2),m=i.shape.slice(0,-2),v=fv(d),g=fv(m);lv(u>=2&&l>=2&&(v===g||1===v||1===g),(function(){return"Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of ("+d+") and ("+m+")."}));var y=(v>g?a.shape.slice(0,-2):i.shape.slice(0,-2)).concat([h,f]);lv(c===p,(function(){return"Error in matMul: inner shapes ("+c+") and ("+p+") of Tensors with shapes "+a.shape+" and "+i.shape+" and transposeA="+o+" and transposeB="+s+" must match."}));for(var b=s?[g,f,p]:[g,p,f],x=eP({inputs:{x:a},backend:n,attrs:{shape:o?[v,c,h]:[v,h,c]}}),w=eP({inputs:{x:i},backend:n,attrs:{shape:b}}),k=o?x.shape[1]:x.shape[2],N=o?x.shape[2]:x.shape[1],I=s?w.shape[1]:w.shape[2],S=Math.max(v,g),T=n.data.get(x.dataId).values,C=n.data.get(w.dataId).values,E=Lv(x.shape),R=Lv(w.shape),A=o?[E[0],1,E[1]]:[E[0],E[1],1],D=A[0],F=A[1],_=A[2],O=s?[1,R[1],R[0]]:[R[1],1,R[0]],M=O[0],L=O[1],z=O[2],P=N*I,B=nb([S,N,I],x.dtype),W=B.values,V=n.blockSize,U=0;U<S;U++)for(var G=0;G<N;G+=V)for(var j=0;j<I;j+=V)for(var H=0;H<k;H+=V)for(var q=Math.min(G+V,N),K=Math.min(j+V,I),X=Math.min(H+V,k),Y=G;Y<q;Y++)for(var J=j;J<K;J++){for(var Z=0,Q=H;Q<X;Q++){var $=Math.min(U,v-1)*D,ee=Math.min(U,g-1)*z;Z+=T[$+Y*F+Q*_]*C[Q*M+J*L+ee]}W[U*P+(Y*I+J)]+=Z}return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(w),n.makeTensorInfo(y,B.dtype,B.values)}var rP={kernelName:"BatchMatMul",backendName:"cpu",kernelFunc:nP};var aP={kernelName:"_FusedMatMul",backendName:"cpu",kernelFunc:function(e){var t,n,r,a=e.inputs,i=e.backend,o=e.attrs,s=a.a,u=a.b,l=a.bias,c=a.preluActivationWeights,p=o.transposeA,h=o.transposeB,f=o.activation,d=o.leakyreluAlpha,m=[];t=nP({inputs:{a:s,b:u},attrs:{transposeA:p,transposeB:h},backend:i}),l&&(n=BL({inputs:{a:t,b:l},backend:i}),m.push(t),t=n),f&&(r=$z(i,t,f,c,d),m.push(t),t=r);for(var v=0,g=m;v<g.length;v++){var y=g[v];i.disposeIntermediateTensorInfo(y)}return t}},iP={kernelName:"Acos",backendName:"cpu",kernelFunc:jL("Acos",(function(e){return Math.acos(e)}))},oP={kernelName:"Acosh",backendName:"cpu",kernelFunc:jL("Acosh",(function(e){return Math.acosh(e)}))};var sP={kernelName:"AddN",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t;xL(t,"addN");for(var a=r.map((function(e){return n.data.get(e.dataId).values})),i=nb(r[0].shape,r[0].dtype),o=i.values,s=0;s<r.length;s++)for(var u=a[s],l=0;l<o.length;l++)o[l]+=u[l];return n.makeTensorInfo(i.shape,i.dtype,i.values)}};var uP={kernelName:"All",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims;xL(a,"all");var s=xv(i,a.shape),u=s,l=Ik(u,a.shape.length),c=a;null!=l&&(c=Nz({inputs:{x:a},backend:n,attrs:{perm:l}}),u=Tk(u.length,a.shape.length)),Nk("all",u,c.shape.length);for(var p=wk(c.shape,u),h=p[0],f=fv(p[1]),d=Bv(fv(h),c.dtype),m=n.data.get(c.dataId).values,v=0;v<d.length;++v){for(var g=v*f,y=m[g],b=0;b<f;++b){var x=m[g+b];y=y&&x}d[v]=y}null!=l&&n.disposeIntermediateTensorInfo(c);var w=n.makeTensorInfo(h,c.dtype,d);if(o){var k=eP({inputs:{x:w},backend:n,attrs:{shape:kk(h,s)}});return n.disposeIntermediateTensorInfo(w),k}return w}};var lP={kernelName:"Any",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims;xL(a,"any");var s=xv(i,a.shape),u=s,l=Ik(u,a.shape.length),c=a;null!=l&&(c=Nz({inputs:{x:a},backend:n,attrs:{perm:l}}),u=Tk(u.length,a.shape.length)),Nk("any",u,c.shape.length);for(var p=wk(c.shape,u),h=p[0],f=fv(p[1]),d=Bv(fv(h),c.dtype),m=n.data.get(c.dataId).values,v=0;v<d.length;++v){for(var g=v*f,y=m[g],b=0;b<f;++b){var x=m[g+b];y=y||x}d[v]=y}null!=l&&n.disposeIntermediateTensorInfo(c);var w=n.makeTensorInfo(h,c.dtype,d);if(o){var k=eP({inputs:{x:w},backend:n,attrs:{shape:kk(h,s)}});return n.disposeIntermediateTensorInfo(w),k}return w}};var cP={kernelName:"ArgMax",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis;xL(a,"argMax");var o=xv(i,a.shape),s=Ik(o,a.shape.length),u=a,l=[];null!=s&&(u=Nz({inputs:{x:a},backend:n,attrs:{perm:s}}),l.push(u),o=Tk(o.length,u.shape.length)),Nk("argMax",o=[o[0]],u.shape.length);for(var c=wk(u.shape,o),p=c[0],h=c[1],f=Bv(fv(p),"int32"),d=fv(h),m=n.data.get(u.dataId).values,v=0;v<f.length;++v){for(var g=v*d,y=m[g],b=0,x=0;x<d;++x){var w=m[g+x];w>y&&(y=w,b=x)}f[v]=b}return l.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.makeTensorInfo(p,"int32",f)}};var pP={kernelName:"ArgMin",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis;xL(a,"argMin");var o=xv(i,a.shape),s=Ik(o,a.shape.length),u=a,l=[];null!=s&&(u=Nz({inputs:{x:a},backend:n,attrs:{perm:s}}),l.push(u),o=Tk(o.length,u.shape.length)),Nk("argMin",o=[o[0]],u.shape.length);for(var c=wk(u.shape,o),p=c[0],h=c[1],f=Bv(fv(p),"int32"),d=fv(h),m=n.data.get(u.dataId).values,v=0;v<f.length;++v){for(var g=v*d,y=m[g],b=0,x=0;x<d;++x){var w=m[g+x];w<y&&(y=w,b=x)}f[v]=b}return l.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.makeTensorInfo(p,"int32",f)}},hP={kernelName:"Asin",backendName:"cpu",kernelFunc:jL("Asin",(function(e){return Math.asin(e)}))},fP={kernelName:"Asinh",backendName:"cpu",kernelFunc:jL("Asinh",(function(e){return Math.asinh(e)}))},dP={kernelName:"Atan",backendName:"cpu",kernelFunc:jL("Atan",(function(e){return Math.atan(e)}))},mP={kernelName:"Atan2",backendName:"cpu",kernelFunc:ML("Atan2",SL((function(e,t){return Math.atan2(e,t)})))},vP={kernelName:"Atanh",backendName:"cpu",kernelFunc:jL("Atanh",(function(e){return Math.atanh(e)}))};function gP(e,t,n,r,a,i){for(var o=a.strideHeight,s=a.strideWidth,u=a.dilationHeight,l=a.dilationWidth,c=a.effectiveFilterHeight,p=a.effectiveFilterWidth,h=a.padInfo.top,f=a.padInfo.left,d="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=nb(a.outShape,n),v=m.values,g=a.outShape[1]*a.outShape[2]*a.outShape[3],y=a.outShape[2]*a.outShape[3],b=a.outShape[3],x=0;x<a.batchSize;++x)for(var w=x*g,k=x*r[0],N=0;N<a.inChannels;++N)for(var I=0;I<a.outHeight;++I)for(var S=I*o-h,T=Math.max(0,S),C=Math.min(a.inHeight,c+S),E=w+I*y,R=0;R<a.outWidth;++R){for(var A=R*s-f,D=Math.max(0,A),F=Math.min(a.inWidth,p+A),_=d,O=0,M=0,L=T;L<C;L+=u){for(var z=k+L*r[1],P=D;P<F;P+=l){var B=e[z+P*r[2]+N];"max"===i&&B>_?_=B:"avg"===i&&(O+=B,M++)}if(isNaN(_))break}v[E+R*b+N]="avg"===i?O/M:_}return m}function yP(e,t,n,r,a,i){void 0===a&&(a=!1),void 0===i&&(i=!1);for(var o=nb(r.outShape,"int32"),s=r.strideHeight,u=r.strideWidth,l=r.dilationHeight,c=r.dilationWidth,p=r.effectiveFilterHeight,h=r.effectiveFilterWidth,f=r.padInfo.top,d=r.padInfo.left,m=nb(t,n,e),v=0;v<r.batchSize;++v)for(var g=0;g<r.inChannels;++g)for(var y=0;y<r.outHeight;++y){for(var b=y*s-f,x=b;x<0;)x+=l;for(var w=Math.min(r.inHeight,p+b),k=0;k<r.outWidth;++k){for(var N=k*u-d,I=N;I<0;)I+=c;for(var S=Math.min(r.inWidth,h+N),T=Number.NEGATIVE_INFINITY,C=-1,E=x;E<w;E+=l)for(var R=E-b,A=I;A<S;A+=c){var D=A-N,F=m.get(v,E,A,g);F>T&&(T=F,C=a?i?((v*r.inHeight+E)*r.inWidth+A)*r.inChannels+g:(E*r.inWidth+A)*r.inChannels+g:R*h+D)}o.set(C,v,y,k,g)}}return o}function bP(e,t,n,r,a,i){for(var o=a.strideDepth,s=a.strideHeight,u=a.strideWidth,l=a.dilationDepth,c=a.dilationHeight,p=a.dilationWidth,h=a.effectiveFilterDepth,f=a.effectiveFilterHeight,d=a.effectiveFilterWidth,m=a.padInfo.front,v=a.padInfo.top,g=a.padInfo.left,y="max"===i?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,b=nb(a.outShape,n),x=b.values,w=a.outShape[1]*a.outShape[2]*a.outShape[3]*a.outShape[4],k=a.outShape[2]*a.outShape[3]*a.outShape[4],N=a.outShape[3]*a.outShape[4],I=a.outShape[4],S=0;S<a.batchSize;++S)for(var T=S*w,C=S*r[0],E=0;E<a.inChannels;++E)for(var R=0;R<a.outDepth;++R){for(var A=R*o-m,D=A;D<0;)D+=l;for(var F=Math.min(a.inDepth,h+A),_=T+R*k,O=0;O<a.outHeight;++O){for(var M=O*s-v,L=M;L<0;)L+=c;for(var z=Math.min(a.inHeight,f+M),P=_+O*N,B=0;B<a.outWidth;++B){for(var W=B*u-g,V=W;V<0;)V+=p;for(var U=Math.min(a.inWidth,d+W),G=P+B*I,j=y,H=0,q=0,K=D;K<F;K+=l){for(var X=C+K*r[1],Y=L;Y<z;Y+=c){for(var J=X+Y*r[2],Z=V;Z<U;Z+=p){var Q=e[J+Z*r[3]+E];if("max"===i&&Q>j?j=Q:"avg"===i&&(H+=Q,q++),isNaN(j))break}if(isNaN(j))break}if(isNaN(j))break}x[G+E]="avg"===i?H/q:j}}}return b}var xP={kernelName:"AvgPool",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;xL(a,"avgPool");var i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode;lv(Xx(o,1),(function(){return"Error in avgPool: Either strides or dilations must be 1. Got strides "+o+" and dilations '1'"}));var l,c=Px(a.shape,i,o,1,s,u);if(1===c.filterWidth&&1===c.filterHeight&&dv(c.inShape,c.outShape))l=RL({inputs:{x:a},backend:n});else{var p=n.data.get(a.dataId).values,h=Lv(a.shape),f=gP(p,a.shape,a.dtype,h,c,"avg");l=n.makeTensorInfo(c.outShape,a.dtype,f.values)}return l}};var wP={kernelName:"AvgPool3D",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode,l=r.dataFormat,c=r.dilations;xL(a,"avgPool3d");var p=c;null==p&&(p=[1,1,1]);var h=Bx(a.shape,i,o,p,s,u,l),f=bP(n.data.get(a.dataId).values,a.shape,a.dtype,Lv(a.shape),h,"avg");return n.makeTensorInfo(f.shape,"float32",f.values)}};var kP={kernelName:"AvgPool3DGrad",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=r.filterSize,s=r.strides,u=r.pad,l=r.dilations,c=r.dimRoundingMode;xL([a,i],"avgPool3DGrad");for(var p=Bx(i.shape,o,s,l,u,c),h=p.strideDepth,f=p.strideHeight,d=p.strideWidth,m=p.filterDepth,v=p.filterHeight,g=p.filterWidth,y=p.dilationDepth,b=p.dilationHeight,x=p.dilationWidth,w=p.effectiveFilterDepth,k=p.effectiveFilterHeight,N=p.effectiveFilterWidth,I=w-1-p.padInfo.front,S=N-1-p.padInfo.left,T=k-1-p.padInfo.top,C=nb(i.shape,"float32"),E=1/(m*v*g),R=n.bufferSync(a),A=0;A<p.batchSize;++A)for(var D=0;D<p.inChannels;++D)for(var F=0;F<p.inDepth;++F)for(var _=0;_<p.inHeight;++_)for(var O=0;O<p.inWidth;++O){for(var M=F-I,L=_-T,z=O-S,P=0,B=0;B<w;B+=y){var W=(M+B)/h;if(!(W<0||W>=p.outDepth||Math.floor(W)!==W))for(var V=0;V<k;V+=b){var U=(L+V)/f;if(!(U<0||U>=p.outHeight||Math.floor(U)!==U))for(var G=0;G<N;G+=x){var j=(z+G)/d;if(!(j<0||j>=p.outWidth||Math.floor(j)!==j))P+=R.get(A,W,U,j,D)}}}C.set(P*E,A,F,_,O,D)}return n.makeTensorInfo(C.shape,C.dtype,C.values)}};var NP={kernelName:"AvgPoolGrad",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=i;xL([a,i],"avgPoolGrad");for(var s=r.filterSize,u=r.strides,l=r.pad,c=Px(o.shape,s,u,1,l),p=c.strideHeight,h=c.strideWidth,f=c.filterHeight,d=c.filterWidth,m=c.dilationHeight,v=c.dilationWidth,g=c.effectiveFilterHeight,y=c.effectiveFilterWidth,b=y-1-c.padInfo.left,x=g-1-c.padInfo.top,w=nb(o.shape,"float32"),k=1/(f*d),N=n.data.get(a.dataId).values,I=nb(a.shape,"float32",N),S=0;S<c.batchSize;++S)for(var T=0;T<c.inChannels;++T)for(var C=0;C<c.inHeight;++C)for(var E=0;E<c.inWidth;++E){for(var R=C-x,A=E-b,D=0,F=0;F<g;F+=m){var _=(R+F)/p;if(!(_<0||_>=c.outHeight||Math.floor(_)!==_))for(var O=0;O<y;O+=v){var M=(A+O)/h;if(!(M<0||M>=c.outWidth||Math.floor(M)!==M))D+=I.get(S,_,M,T)}}w.set(D*k,S,C,E,T)}return n.makeTensorInfo(w.shape,w.dtype,w.values)}};var IP={kernelName:"FusedBatchNorm",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.scale,o=t.offset,s=t.mean,u=t.variance;lv(s.shape.length===u.shape.length,(function(){return"Batch normalization gradient requires mean and variance to have equal ranks."})),lv(null==o||s.shape.length===o.shape.length,(function(){return"Batch normalization gradient requires mean and offset to have equal ranks."})),lv(null==i||s.shape.length===i.shape.length,(function(){return"Batch normalization gradient requires mean and scale to have equal ranks."})),xL([a,s,u,i,o],"batchNorm");var l=r.varianceEpsilon;null==l&&(l=.001);for(var c=n.data.get(a.dataId).values,p=n.data.get(s.dataId).values,h=n.data.get(u.dataId).values,f=i?n.data.get(i.dataId).values:new Float32Array([1]),d=o?n.data.get(o.dataId).values:new Float32Array([0]),m=new Float32Array(c.length),v=d.length,g=f.length,y=h.length,b=p.length,x=0,w=0,k=0,N=0,I=0;I<c.length;++I)m[I]=d[x++]+(c[I]-p[w++])*f[k++]/Math.sqrt(h[N++]+l),x>=v&&(x=0),w>=b&&(w=0),k>=g&&(k=0),N>=y&&(N=0);return n.makeTensorInfo(a.shape,a.dtype,m)}};var SP={kernelName:"BatchToSpaceND",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockShape,o=r.crops;xL([a],"batchToSpaceND");var s=i.reduce((function(e,t){return e*t})),u=uT(a.shape,i,s),l=lT(u.length,i.length),c=cT(a.shape,i,s),p=pT(o,i.length),h=hT(c,o,i.length),f=eP({inputs:{x:a},backend:n,attrs:{shape:u}}),d=Nz({inputs:{x:f},backend:n,attrs:{perm:l}}),m=eP({inputs:{x:d},backend:n,attrs:{shape:c}}),v=Dz({inputs:{x:m},backend:n,attrs:{begin:p,size:h}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(m),v}};var TP={kernelName:"Bincount",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.weights,o=r.size,s=VL(n.data.get(a.dataId).values,n.data.get(i.dataId).values,i.dtype,i.shape,o);return n.makeTensorInfo([o],i.dtype,s)}},CP={kernelName:"ClipByValue",backendName:"cpu",kernelFunc:jL("ClipByValue",(function(e,t){var n=t;return e>n.clipValueMax?n.clipValueMax:e<n.clipValueMin?n.clipValueMin:e}))},EP={kernelName:"ComplexAbs",backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs.x,n=e.backend,r=new Float32Array(fv(t.shape)),a=n.data.get(t.dataId),i=a.complexTensorInfos.real,o=a.complexTensorInfos.imag,s=n.data.get(i.dataId).values,u=n.data.get(o.dataId).values,l=0;l<s.length;l++){var c=s[l],p=u[l];r[l]=Math.hypot(c,p)}return n.makeOutput(r,t.shape,"float32")}};function RP(e){var t=e.inputs,n=e.backend,r=t.input,a=n.data.get(r.dataId).complexTensorInfos.imag,i=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,i)}var AP={kernelName:"Imag",backendName:"cpu",kernelFunc:RP};function DP(e){var t=e.inputs,n=e.backend,r=xv(e.attrs.axis,t[0].shape)[0],a=iT(t.map((function(e){return e.shape})),r);if(0===fv(a))return n.makeTensorInfo(a,t[0].dtype,[]);var i=t.filter((function(e){return fv(e.shape)>0}));if(1===i.length)return RL({inputs:{x:i[0]},backend:n});if(aT(i.map((function(e){return e.shape})),r),"complex64"===i[0].dtype){var o=i.map((function(e){return DL({inputs:{input:e},backend:n})})),s=i.map((function(e){return RP({inputs:{input:e},backend:n})})),u=DP({inputs:o,backend:n,attrs:{axis:r}}),l=DP({inputs:s,backend:n,attrs:{axis:r}}),c=TL({inputs:{real:u,imag:l},backend:n});return o.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),s.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(l),c}var p=i.map((function(e){var t=fv(e.shape.slice(r));return eP({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})}));a=iT(p.map((function(e){return e.shape})),1);var h=kv(i[0].dtype,fv(a));if(1===p[0].shape[0]){var f=0;p.forEach((function(e){var t=n.data.get(e.dataId).values,r=fv(e.shape);h.set(t,f),f+=r}))}else{var d=0;p.forEach((function(e){for(var t=n.data.get(e.dataId).values,r=0,i=0;i<e.shape[0];++i)for(var o=i*a[1]+d,s=0;s<e.shape[1];++s)h[o+s]=t[r++];d+=e.shape[1]}))}var m=iT(i.map((function(e){return e.shape})),r),v=n.makeTensorInfo(m,t[0].dtype,h);return p.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),v}var FP={kernelName:"Concat",backendName:"cpu",kernelFunc:DP};function _P(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dataFormat,l=r.dilations,c=r.dimRoundingMode;xL([a,i],"conv2d");for(var p=Yx(u),h=Wx(a.shape,i.shape,o,l,s,c,!1,p),f=h.filterHeight,d=h.filterWidth,m=h.dilationHeight,v=h.dilationWidth,g=h.padInfo.left,y=h.padInfo.top,b="channelsLast"===h.dataFormat,x=new Rg(h.outShape,a.dtype),w=Lv(a.shape),k=Lv(i.shape),N=w[0],I=b?w[1]:w[2],S=b?w[2]:1,T=b?1:w[1],C=x.strides[0],E=b?x.strides[1]:x.strides[2],R=b?x.strides[2]:1,A=b?1:x.strides[1],D=n.data.get(a.dataId).values,F=n.data.get(i.dataId).values,_=x.values,O=0;O<h.batchSize;++O)for(var M=O*N,L=O*C,z=0;z<h.outHeight;++z)for(var P=L+z*E,B=z*h.strideHeight-y,W=0;W<f;++W){var V=B+W*m;if(!(V<0||V>=h.inHeight))for(var U=W*k[0],G=M+V*I,j=0;j<h.outWidth;++j)for(var H=P+j*R,q=j*h.strideWidth-g,K=0;K<d;++K){var X=q+K*v;if(!(X<0||X>=h.inWidth))for(var Y=G+X*S,J=U+K*k[1],Z=0;Z<h.inChannels;++Z){for(var Q=D[Y+Z*T],$=0;$<h.outChannels;++$)_[H+$*A]+=Q*F[J+$];J+=h.outChannels}}}return n.makeTensorInfo(x.shape,x.dtype,_)}var OP={kernelName:"Conv2D",backendName:"cpu",kernelFunc:_P};var MP={kernelName:"Conv2DBackpropFilter",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.pad,u=r.dataFormat,l=r.dimRoundingMode,c=r.filterShape;xL([a,i],"conv2dBackpropFilter");for(var p=Yx(u),h=Wx(a.shape,c,o,1,s,l,!1,p),f=h.strideHeight,d=h.strideWidth,m=h.filterHeight,v=h.filterWidth,g="channelsLast"===h.dataFormat,y=new Rg(h.filterShape,"float32"),b=h.padInfo.left,x=h.padInfo.top,w=n.data.get(a.dataId).values,k=n.data.get(i.dataId).values,N=new Rg(a.shape,a.dtype,w),I=new Rg(i.shape,i.dtype,k),S=0;S<m;++S)for(var T=Math.max(0,Math.ceil((x-S)/f)),C=Math.min(h.outHeight,(h.inHeight+x-S)/f),E=0;E<v;++E)for(var R=Math.max(0,Math.ceil((b-E)/d)),A=Math.min(h.outWidth,(h.inWidth+b-E)/d),D=0;D<h.inChannels;++D)for(var F=0;F<h.outChannels;++F){for(var _=0,O=0;O<h.batchSize;++O)for(var M=T;M<C;++M)for(var L=S+M*f-x,z=R;z<A;++z){var P=E+z*d-b;_+=g?N.get(O,L,P,D)*I.get(O,M,z,F):N.get(O,D,L,P)*I.get(O,F,M,z)}y.set(_,S,E,D,F)}return n.makeTensorInfo(y.shape,y.dtype,y.values)}};var LP={kernelName:"Conv2DBackpropInput",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.inputShape,s=r.strides,u=r.pad,l=r.dataFormat,c=r.dimRoundingMode;xL([a,i],"conv2dBackpropInput");var p=Lv(i.shape),h=Lv(a.shape),f=Yx(l),d=Wx(o,i.shape,s,1,u,c,!1,f),m=new Rg(d.inShape,"float32"),v=m.values,g=n.data.get(a.dataId).values,y=n.data.get(i.dataId).values,b=p[0],x=p[1],w=p[2],k=d.batchSize,N=d.filterHeight,I=d.filterWidth,S=d.inChannels,T=d.inHeight,C=d.inWidth,E=d.outChannels,R=d.outHeight,A=d.outWidth,D=d.strideHeight,F=d.strideWidth;f=d.dataFormat;for(var _=N-1-d.padInfo.top,O=I-1-d.padInfo.left,M="channelsLast"===f,L=m.strides[0],z=M?m.strides[1]:m.strides[2],P=M?m.strides[2]:1,B=M?1:m.strides[1],W=h[0],V=M?h[1]:h[2],U=M?h[2]:1,G=M?1:h[1],j=0;j<k;++j)for(var H=0;H<S;++H)for(var q=0;q<T;++q)for(var K=q-_,X=Math.max(0,Math.ceil(K/D)),Y=Math.min(R,(N+K)/D),J=0;J<C;++J){for(var Z=J-O,Q=Math.max(0,Math.ceil(Z/F)),$=Math.min(A,(I+Z)/F),ee=0,te=X;te<Y;++te)for(var ne=te*D-K,re=Q;re<$;++re)for(var ae=W*j+V*te+U*re,ie=b*(N-1-ne)+x*(I-1-(re*F-Z))+w*H,oe=0;oe<E;++oe){ee+=g[ae+G*oe]*y[ie+oe]}v[L*j+z*q+P*J+B*H]=ee}return n.makeTensorInfo(m.shape,m.dtype,m.values)}};var zP={kernelName:"Conv3D",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dilations;xL([a,i],"conv3d");for(var l=Vx(a.shape,i.shape,o,u,s),c=l.filterDepth,p=l.filterHeight,h=l.filterWidth,f=l.dilationDepth,d=l.dilationHeight,m=l.dilationWidth,v=l.padInfo,g=v.front,y=v.left,b=v.top,x=new Rg(l.outShape,a.dtype),w=n.data.get(a.dataId).values,k=n.data.get(i.dataId).values,N=x.values,I=Lv(a.shape),S=Lv(i.shape),T=0;T<l.batchSize;++T)for(var C=T*I[0],E=T*x.strides[0],R=0;R<l.outDepth;++R)for(var A=E+R*x.strides[1],D=R*l.strideDepth-g,F=0;F<c;++F){var _=D+F*f;if(!(_<0||_>=l.inDepth))for(var O=F*S[0],M=C+_*I[1],L=0;L<l.outHeight;++L)for(var z=A+L*x.strides[2],P=L*l.strideHeight-b,B=0;B<p;++B){var W=P+B*d;if(!(W<0||W>=l.inHeight))for(var V=O+B*S[1],U=M+W*I[2],G=0;G<l.outWidth;++G)for(var j=z+G*l.outChannels,H=G*l.strideWidth-y,q=0;q<h;++q){var K=H+q*m;if(!(K<0||K>=l.inWidth))for(var X=V+q*S[2],Y=U+K*l.inChannels,J=X,Z=0;Z<l.inChannels;++Z){for(var Q=w[Y+Z],$=0;$<l.outChannels;++$)N[j+$]+=Q*k[J+$];J+=l.outChannels}}}}return n.makeTensorInfo(x.shape,x.dtype,x.values)}};var PP={kernelName:"Conv3DBackpropFilterV2",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.pad,u=r.filterShape;xL([a,i],"conv3dBackpropFilterV2");for(var l=Lv(a.shape),c=Lv(i.shape),p=Vx(a.shape,u,o,1,s),h=p.strideDepth,f=p.strideHeight,d=p.strideWidth,m=p.filterDepth,v=p.filterHeight,g=p.filterWidth,y=new Rg(p.filterShape,"float32"),b=y.values,x=y.strides,w=x[0],k=x[1],N=x[2],I=x[3],S=n.data.get(i.dataId).values,T=c[0],C=c[1],E=c[2],R=c[3],A=n.data.get(a.dataId).values,D=l[0],F=l[1],_=l[2],O=l[3],M=p.padInfo.front,L=p.padInfo.left,z=p.padInfo.top,P=0;P<m;++P)for(var B=Math.max(0,Math.ceil((M-P)/h)),W=Math.min(p.outDepth,(p.inDepth+M-P)/h),V=P*w,U=0;U<v;++U)for(var G=Math.max(0,Math.ceil((z-U)/f)),j=Math.min(p.outHeight,(p.inHeight+z-U)/f),H=U*k+V,q=0;q<g;++q)for(var K=Math.max(0,Math.ceil((L-q)/d)),X=Math.min(p.outWidth,(p.inWidth+L-q)/d),Y=q*N+H,J=0;J<p.inChannels;++J)for(var Z=J*I+Y,Q=0;Q<p.outChannels;++Q){for(var $=0,ee=0;ee<p.batchSize;++ee)for(var te=ee*D,ne=ee*T,re=B;re<W;++re)for(var ae=(P+re*h-M)*F+te,ie=re*C+ne,oe=G;oe<j;++oe)for(var se=(U+oe*f-z)*_+ae,ue=oe*E+ie,le=K;le<X;++le){var ce=le*R+ue;$+=A[(q+le*d-L)*O+se+J]*S[ce+Q]}b[Z+Q]=$}return n.makeTensorInfo(y.shape,y.dtype,y.values)}};var BP={kernelName:"Conv3DBackpropInputV2",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.pad,s=r.strides,u=r.inputShape;xL([a],"conv3dBackpropInputV2");for(var l=Lv(a.shape),c=Lv(i.shape),p=Vx(u,i.shape,s,1,o),h=new Rg(p.inShape,"float32"),f=h.values,d=h.strides,m=d[0],v=d[1],g=d[2],y=d[3],b=n.data.get(a.dataId).values,x=l[0],w=l[1],k=l[2],N=l[3],I=n.data.get(i.dataId).values,S=c[0],T=c[1],C=c[2],E=c[3],R=p.batchSize,A=p.filterDepth,D=p.filterHeight,F=p.filterWidth,_=p.inChannels,O=p.inDepth,M=p.inHeight,L=p.inWidth,z=p.outChannels,P=p.outDepth,B=p.outHeight,W=p.outWidth,V=p.strideDepth,U=p.strideHeight,G=p.strideWidth,j=A-1-p.padInfo.front,H=D-1-p.padInfo.top,q=F-1-p.padInfo.left,K=0;K<R;++K)for(var X=0;X<_;++X)for(var Y=0;Y<O;++Y)for(var J=Y-j,Z=Math.max(0,Math.ceil(J/V)),Q=Math.min(P,(A+J)/V),$=0;$<M;++$)for(var ee=$-H,te=Math.max(0,Math.ceil(ee/U)),ne=Math.min(B,(D+ee)/U),re=0;re<L;++re){for(var ae=re-q,ie=Math.max(0,Math.ceil(ae/G)),oe=Math.min(W,(F+ae)/G),se=0,ue=Z;ue<Q;++ue)for(var le=ue*V-J,ce=te;ce<ne;++ce)for(var pe=ce*U-ee,he=ie;he<oe;++he)for(var fe=x*K+w*ue+k*ce+N*he,de=S*(A-1-le)+T*(D-1-pe)+C*(F-1-(he*G-ae))+E*X,me=0;me<z;++me){se+=b[fe+me]*I[de+me]}f[m*K+v*Y+g*$+y*re+X]=se}return n.makeTensorInfo(h.shape,h.dtype,h.values)}},WP=jL(Qv,(function(e){return Math.cos(e)})),VP={kernelName:Qv,backendName:"cpu",kernelFunc:WP},UP={kernelName:"Cosh",backendName:"cpu",kernelFunc:jL("Cosh",(function(e){return Math.cosh(e)}))};var GP={kernelName:"CropAndResize",backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs,n=e.backend,r=e.attrs,a=t.image,i=t.boxes,o=t.boxInd,s=r.cropSize,u=r.method,l=r.extrapolationValue,c=a.shape,p=c[0],h=c[1],f=c[2],d=c[3],m=i.shape[0],v=s[0],g=s[1],y=nb([m,v,g,d],"float32"),b=n.data.get(i.dataId).values,x=n.data.get(o.dataId).values,w=n.data.get(a.dataId).values,k=Lv(a.shape),N=Lv(y.shape),I=0;I<m;I++){var S=4*I,T=b[S],C=b[S+1],E=b[S+2],R=b[S+3],A=x[I];if(!(A>=p))for(var D=v>1?(E-T)*(h-1)/(v-1):0,F=g>1?(R-C)*(f-1)/(g-1):0,_=0;_<v;_++){var O=v>1?T*(h-1)+_*D:.5*(T+E)*(h-1);if(O<0||O>h-1)for(var M=0;M<g;M++)for(var L=0;L<d;L++){var z=L+M*N[2]+_*N[1]+I*N[0];y.values[z]=l}else if("bilinear"===u)for(var P=Math.floor(O),B=Math.ceil(O),W=O-P,V=0;V<g;V++){var U=g>1?C*(f-1)+V*F:.5*(C+R)*(f-1);if(U<0||U>f-1)for(var G=0;G<d;G++){var j=G+V*N[2]+_*N[1]+I*N[0];y.values[j]=l}else for(var H=Math.floor(U),q=Math.ceil(U),K=U-H,X=0;X<d;X++){var Y=X+H*k[2]+P*k[1]+A*k[0],J=w[Y],Z=w[Y=X+q*k[2]+P*k[1]+A*k[0]],Q=w[Y=X+H*k[2]+B*k[1]+A*k[0]],$=J+(Z-J)*K,ee=Q+(w[Y=X+q*k[2]+B*k[1]+A*k[0]]-Q)*K;Y=X+V*N[2]+_*N[1]+I*N[0],y.values[Y]=$+(ee-$)*W}}else for(var te=0;te<g;++te){var ne=g>1?C*(f-1)+te*F:.5*(C+R)*(f-1);if(ne<0||ne>f-1)for(var re=0;re<d;re++){var ae=re+te*N[2]+_*N[1]+I*N[0];y.values[ae]=l}else for(var ie=Math.round(ne),oe=Math.round(O),se=0;se<d;se++){var ue=se+ie*k[2]+oe*k[1]+A*k[0],le=se+te*N[2]+_*N[1]+I*N[0];y.values[le]=w[ue]}}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}};var jP={kernelName:"Cumsum",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.exclusive,s=r.reverse;xL(a,"cumsum");var u=Ik([i],a.shape.length),l=a;null!=u&&(l=Nz({inputs:{x:a},backend:n,attrs:{perm:u}}));var c=Tk(1,a.shape.length)[0];if(c!==l.shape.length-1)throw new Error("backend.cumsum in CPU expects an inner-most axis="+(l.shape.length-1)+" but got axis="+c);for(var p=Wg(l.dtype,"int32"),h=Bv(fv(l.shape),p),f=n.data.get(l.dataId).values,d=l.shape[l.shape.length-1],m=s?function(e,t){return e+d-t-1}:function(e,t){return e+t},v=0;v<f.length;v+=d)for(var g=0;g<d;g++){var y=m(v,g);if(0===g)h[y]=o?0:f[y];else{var b=m(v,g-1);h[y]=o?f[b]+h[b]:f[y]+h[b]}}var x=n.makeTensorInfo(l.shape,p,h);if(null!=u){var w=Nz({inputs:{x:x},backend:n,attrs:{perm:Sk(u)}});return n.disposeIntermediateTensorInfo(x),n.disposeIntermediateTensorInfo(l),w}return x}};var HP={kernelName:"DenseBincount",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.weights,o=r.size,s=r.binaryOutput;if(1===a.shape.length){var u=VL(n.data.get(a.dataId).values,n.data.get(i.dataId).values,i.dtype,i.shape,o);return n.makeTensorInfo([o],i.dtype,u)}if(2===a.shape.length){var l=UL(n.bufferSync(a),n.bufferSync(i),o,s);return n.makeTensorInfo(l.shape,i.dtype,l.values)}throw new Error("Error in denseBincount: input must be at most rank 2, but got rank"+a.shape.length+".")}};var qP={kernelName:"DepthToSpace",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockSize,o=r.dataFormat;lv("NHWC"===o,(function(){return"Only NHWC dataFormat supported on CPU for depthToSpace. Got "+o})),lv(i>1,(function(){return"blockSize should be > 1 for depthToSpace, but was: "+i}));for(var s=a.shape[0],u=a.shape[1],l=a.shape[2],c=a.shape[3],p=u*i,h=l*i,f=c/(i*i),d=n.data.get(a.dataId).values,m=new Float32Array(s*p*h*f),v=0,g=0;g<s;++g)for(var y=0;y<p;++y)for(var b=Math.floor(y/i),x=y%i,w=0;w<h;++w)for(var k=Math.floor(w/i),N=(x*i+w%i)*f,I=0;I<f;++I){var S=I+N+c*(k+l*(b+u*g));m[v++]=d[S]}return n.makeTensorInfo([s,p,h,f],a.dtype,m)}};function KP(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dilations,l=r.dimRoundingMode;xL([a,i],"depthwiseConv2DNative");var c=Lv(a.shape),p=Lv(i.shape),h=u;null==h&&(h=[1,1]),lv(Xx(o,h),(function(){return"Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+h+"'"}));for(var f=Wx(a.shape,i.shape,o,h,s,l,!0),d=f.filterHeight,m=f.filterWidth,v=f.dilationHeight,g=f.dilationWidth,y=f.padInfo,b=y.left,x=y.top,w=f.outChannels/f.inChannels,k=new Rg(f.outShape,a.dtype),N=n.data.get(a.dataId).values,I=n.data.get(i.dataId).values,S=k.values,T=0;T<f.batchSize;++T)for(var C=T*c[0],E=T*k.strides[0],R=0;R<f.outHeight;++R)for(var A=E+R*k.strides[1],D=R*f.strideHeight-b,F=0;F<d;++F){var _=D+F*v;if(!(_<0||_>=f.inHeight))for(var O=F*p[0],M=C+_*c[1],L=0;L<f.outWidth;++L)for(var z=A+L*k.strides[2],P=L*f.strideWidth-x,B=0;B<m;++B){var W=P+B*g;if(!(W<0||W>=f.inWidth))for(var V=O+B*p[1],U=M+W*f.inChannels,G=z,j=V,H=0;H<f.inChannels;++H){for(var q=N[U+H],K=0;K<w;++K)S[G+K]+=q*I[j+K];G+=w,j+=w}}}return n.makeTensorInfo(k.shape,k.dtype,k.values)}var XP={kernelName:"DepthwiseConv2dNative",backendName:"cpu",kernelFunc:KP};var YP={kernelName:"DepthwiseConv2dNativeBackpropFilter",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.dilations,u=r.pad,l=r.dimRoundingMode,c=r.filterShape;xL([a,i],"depthwiseConv2dNativeBackpropFilter");for(var p=Wx(a.shape,c,o,s,u,l,!0),h=p.strideHeight,f=p.strideWidth,d=p.filterHeight,m=p.filterWidth,v=new Rg(p.filterShape,"float32"),g=p.padInfo.left,y=p.padInfo.top,b=p.outChannels/p.inChannels,x=n.data.get(a.dataId).values,w=new Rg(a.shape,a.dtype,x),k=n.data.get(i.dataId).values,N=new Rg(i.shape,i.dtype,k),I=0;I<d;++I)for(var S=Math.max(0,Math.ceil((y-I)/h)),T=Math.min(p.outHeight,(p.inHeight+y-I)/h),C=0;C<m;++C)for(var E=Math.max(0,Math.ceil((g-C)/f)),R=Math.min(p.outWidth,(p.inWidth+g-C)/f),A=0;A<p.outChannels;++A){for(var D=Math.trunc(A/b),F=A%b,_=0,O=0;O<p.batchSize;++O)for(var M=S;M<T;++M)for(var L=I+M*h-y,z=E;z<R;++z){var P=C+z*f-g;_+=w.get(O,L,P,D)*N.get(O,M,z,A)}v.set(_,I,C,D,F)}return n.makeTensorInfo(v.shape,v.dtype,v.values)}};var JP={kernelName:"DepthwiseConv2dNativeBackpropInput",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.strides,s=r.dilations,u=r.pad,l=r.dimRoundingMode,c=r.inputShape;xL([a,i],"depthwiseConv2DNativeBackpropInput");for(var p=Lv(a.shape),h=Lv(i.shape),f=Wx(c,i.shape,o,s,u,l,!0),d=new Rg(f.inShape,"float32"),m=d.values,v=d.strides,g=v[0],y=v[1],b=v[2],x=n.data.get(a.dataId).values,w=p[0],k=p[1],N=p[2],I=n.data.get(i.dataId).values,S=h[0],T=h[1],C=h[2],E=f.batchSize,R=f.filterHeight,A=f.filterWidth,D=f.inChannels,F=f.inHeight,_=f.inWidth,O=f.outChannels,M=f.outHeight,L=f.outWidth,z=f.strideHeight,P=f.strideWidth,B=R-1-f.padInfo.top,W=A-1-f.padInfo.left,V=O/D,U=0;U<E;++U)for(var G=0;G<D;++G)for(var j=0;j<F;++j)for(var H=j-B,q=Math.max(0,Math.ceil(H/z)),K=Math.min(M,(R+H)/z),X=0;X<_;++X){for(var Y=X-W,J=Math.max(0,Math.ceil(Y/P)),Z=Math.min(L,(A+Y)/P),Q=0,$=q;$<K;++$)for(var ee=$*z-H,te=J;te<Z;++te)for(var ne=w*U+k*$+N*te,re=S*(R-1-ee)+T*(A-1-(te*P-Y))+C*G,ae=0;ae<V;++ae){Q+=x[ne+(G*V+ae)]*I[re+ae]}m[g*U+y*j+b*X+G]=Q}return n.makeTensorInfo(d.shape,d.dtype,d.values)}};var ZP={kernelName:"Diag",backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs,n=e.backend,r=t.x,a=fv(r.shape),i=n.data.get(r.dataId).values,o=nb([a,a],r.dtype),s=o.values,u=0;u<i.length;u++)s[u*a+u]=i[u];var l=[].concat(r.shape,r.shape);return n.makeTensorInfo(l,o.dtype,o.values)}},QP={kernelName:"Dilation2D",backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dilations,l=n,c=l.data.get(a.dataId).values,p=a.shape.length,h=l.data.get(i.dataId).values,f=i.shape.length,d=zx(a.shape,i.shape,o,s,"NHWC",u),m=d.batchSize,v=d.inHeight,g=d.inWidth,y=d.inChannels,b=d.outHeight,x=d.outWidth,w=d.padInfo,k=d.strideHeight,N=d.strideWidth,I=d.filterHeight,S=d.filterWidth,T=d.dilationHeight,C=d.dilationWidth,E=d.outShape,R=fv(E),A=E.length,D=Nv(a.dtype,R),F=0;F<m;++F)for(var _=0;_<b;++_)for(var O=_*k-w.top,M=0;M<x;++M)for(var L=M*N-w.left,z=0;z<y;++z){for(var P=Number.MIN_SAFE_INTEGER,B=0;B<I;++B){var W=O+B*T;if(W>=0&&W<v)for(var V=0;V<S;++V){var U=L+V*C;if(U>=0&&U<g){var G=Uv([F,W,U,z],p,Lv(a.shape)),j=Uv([B,V,z],f,Lv(i.shape)),H=c[G]+h[j];H>P&&(P=H)}}}D[Uv([F,_,M,z],A,Lv(E))]=P}return{dataId:l.write(gg(D,a.dtype),E,a.dtype),shape:E,dtype:a.dtype}}},$P={kernelName:"Dilation2DBackpropFilter",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=t.dy,s=r.strides,u=r.pad,l=r.dilations,c=n,p=zv(a.shape,c.data.get(a.dataId).values),h=zv(i.shape,c.data.get(i.dataId).values),f=zx(a.shape,i.shape,s,u,"NHWC",l),d=f.batchSize,m=f.inHeight,v=f.inWidth,g=f.inChannels,y=f.outHeight,b=f.outWidth,x=f.padInfo,w=f.strideHeight,k=f.strideWidth,N=f.filterHeight,I=f.filterWidth,S=f.dilationHeight,T=f.dilationWidth,C=f.outShape;lv(o.rank===C.length,(function(){return"Error in Dilation2DBackpropFilter, dy must have the same rank as output "+C.length+", but got "+o.rank}));for(var E=zv(C,c.data.get(o.dataId).values),R=Wv(i.shape,i.dtype),A=0;A<d;++A)for(var D=0;D<y;++D)for(var F=D*w-x.top,_=0;_<b;++_)for(var O=_*k-x.left,M=0;M<g;++M){for(var L=Number.MIN_SAFE_INTEGER,z=0,P=0,B=0;B<N;++B){var W=F+B*S;if(W>=0&&W<m)for(var V=0;V<I;++V){var U=O+V*T;if(U>=0&&U<v){var G=p[A][W][U][M]+h[B][V][M];G>L&&(L=G,z=B,P=V)}}}R[z][P][M]+=E[A][D][_][M]}return{dataId:c.write(gg(R,a.dtype),i.shape,i.dtype),shape:i.shape,dtype:i.dtype}}},eB={kernelName:"Dilation2DBackpropInput",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=t.dy,s=r.strides,u=r.pad,l=r.dilations,c=n,p=zv(a.shape,c.data.get(a.dataId).values),h=zv(i.shape,c.data.get(i.dataId).values),f=zx(a.shape,i.shape,s,u,"NHWC",l),d=f.batchSize,m=f.inHeight,v=f.inWidth,g=f.inChannels,y=f.outHeight,b=f.outWidth,x=f.padInfo,w=f.strideHeight,k=f.strideWidth,N=f.filterHeight,I=f.filterWidth,S=f.dilationHeight,T=f.dilationWidth,C=f.outShape;lv(o.rank===C.length,(function(){return"Error in Dilation2DBackpropInput, dy must have the same rank as output "+C.length+", but got "+o.rank}));for(var E=zv(C,c.data.get(o.dataId).values),R=Wv(a.shape,a.dtype),A=0;A<d;++A)for(var D=0;D<y;++D)for(var F=D*w-x.top,_=0;_<b;++_)for(var O=_*k-x.left,M=0;M<g;++M){for(var L=Number.MIN_SAFE_INTEGER,z=F<0?0:F,P=O<0?0:O,B=0;B<N;++B){var W=F+B*S;if(W>=0&&W<m)for(var V=0;V<I;++V){var U=O+V*T;if(U>=0&&U<v){var G=p[A][W][U][M]+h[B][V][M];G>L&&(L=G,z=W,P=U)}}}R[A][z][P][M]+=E[A][D][_][M]}return{dataId:c.write(gg(R,a.dtype),a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}};var tB={kernelName:"EluGrad",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.dy,a=t.y;xL([r,a],"eluGrad");for(var i=new Float32Array(fv(a.shape)),o=n.data.get(a.dataId).values,s=n.data.get(r.dataId).values,u=0;u<o.length;++u){var l=o[u];i[u]=l>=1?s[u]:s[u]*(l+1)}return n.makeTensorInfo(a.shape,"float32",i)}},nB=ML("Equal",SL((function(e,t){return e===t?1:0})),null,"bool"),rB={kernelName:"Equal",backendName:"cpu",kernelFunc:nB},aB=jL(eg,(function(e){var t=Math.sign(e),n=Math.abs(e),r=1/(1+.3275911*n);return t*(1-((((1.061405429*r-1.453152027)*r+1.421413741)*r-.284496736)*r+.254829592)*r*Math.exp(-n*n))})),iB={kernelName:eg,backendName:"cpu",kernelFunc:aB};function oB(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.input,i=r.dim,o=a.shape.length,s=a.shape.slice(),u=i;return i<0&&(lv(-(o+1)<=i,(function(){return"Axis must be in the interval ["+-(o+1)+", "+o+"]"})),u=o+i+1),s.splice(u,0,1),eP({inputs:{x:a},backend:n,attrs:{shape:s}})}var sB={kernelName:"ExpandDims",backendName:"cpu",kernelFunc:oB},uB=ML("RealDiv",SL((function(e,t){return e/t}))),lB={kernelName:"RealDiv",backendName:"cpu",kernelFunc:uB};function cB(e,t,n){for(var r=e.shape,a=r[0],i=r[1],o=n.data.get(e.dataId),s=o.complexTensorInfos.real,u=o.complexTensorInfos.imag,l=[a,i],c=fv(l),p=kv("float32",c),h=kv("float32",c),f=0;f<a;f++){for(var d=Dz({inputs:{x:s},backend:n,attrs:{begin:[f,0],size:[1,i]}}),m=Dz({inputs:{x:u},backend:n,attrs:{begin:[f,0],size:[1,i]}}),v=TL({inputs:{real:d,imag:m},backend:n}),g=pB(v,t,n),y=mT(g.real,g.imag),b=0;b<i;b++){var x=bT(y,b);p[f*i+b]=x.real,h[f*i+b]=x.imag}n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v)}var w=n.makeTensorInfo(l,"float32",p),k=n.makeTensorInfo(l,"float32",h),N=TL({inputs:{real:w,imag:k},backend:n});return n.disposeIntermediateTensorInfo(w),n.disposeIntermediateTensorInfo(k),N}function pB(e,t,n){var r,a=fv(e.shape),i=n.data.get(e.dataId),o=n.data.get(i.complexTensorInfos.real.dataId).values,s=n.data.get(i.complexTensorInfos.imag.dataId).values;if(0==((r=a)&r-1)){var u=function e(t,n,r,a,i){if(1===r)return{real:t,imag:n};var o=mT(t,n),s=r/2,u=gT(o),l=u.real,c=u.imag,p=[l.length],h=i.makeTensorInfo(p,"float32",l),f=i.makeTensorInfo(p,"float32",c),d=TL({inputs:{real:h,imag:f},backend:i}),m=yT(o),v=m.real,g=m.imag,y=[v.length],b=i.makeTensorInfo(y,"float32",v),x=i.makeTensorInfo(y,"float32",g),w=TL({inputs:{real:b,imag:x},backend:i}),k=e(l,c,s,a,i),N=k.real,I=k.imag,S=[N.length],T=i.makeTensorInfo(S,"float32",N),C=i.makeTensorInfo(S,"float32",I),E=TL({inputs:{real:T,imag:C},backend:i}),R=e(v,g,s,a,i),A=R.real,D=R.imag,F=[A.length],_=i.makeTensorInfo(F,"float32",A),O=i.makeTensorInfo(F,"float32",D),M=TL({inputs:{real:_,imag:O},backend:i}),L=wT(r,a),z=[L.real.length],P=i.makeTensorInfo(z,"float32",L.real),B=i.makeTensorInfo(z,"float32",L.imag),W=TL({inputs:{real:P,imag:B},backend:i}),V=gz({inputs:{a:W,b:M},backend:i}),U=BL({inputs:{a:E,b:V},backend:i}),G=zz({inputs:{a:E,b:V},backend:i}),j=DL({inputs:{input:U},backend:i}),H=DL({inputs:{input:G},backend:i}),q=RP({inputs:{input:U},backend:i}),K=RP({inputs:{input:G},backend:i}),X=DP({inputs:[j,H],backend:i,attrs:{axis:0}}),Y=DP({inputs:[q,K],backend:i,attrs:{axis:0}}),J=i.data.get(X.dataId).values,Z=i.data.get(Y.dataId).values;return i.disposeIntermediateTensorInfo(h),i.disposeIntermediateTensorInfo(f),i.disposeIntermediateTensorInfo(d),i.disposeIntermediateTensorInfo(b),i.disposeIntermediateTensorInfo(x),i.disposeIntermediateTensorInfo(w),i.disposeIntermediateTensorInfo(T),i.disposeIntermediateTensorInfo(C),i.disposeIntermediateTensorInfo(E),i.disposeIntermediateTensorInfo(_),i.disposeIntermediateTensorInfo(O),i.disposeIntermediateTensorInfo(M),i.disposeIntermediateTensorInfo(P),i.disposeIntermediateTensorInfo(B),i.disposeIntermediateTensorInfo(W),i.disposeIntermediateTensorInfo(V),i.disposeIntermediateTensorInfo(U),i.disposeIntermediateTensorInfo(G),i.disposeIntermediateTensorInfo(j),i.disposeIntermediateTensorInfo(q),i.disposeIntermediateTensorInfo(H),i.disposeIntermediateTensorInfo(K),i.disposeIntermediateTensorInfo(X),i.disposeIntermediateTensorInfo(Y),{real:J,imag:Z}}(o,s,a,t,n),l=[e.shape[0],e.shape[1]];if(t){var c=n.makeTensorInfo(l,"float32",u.real),p=n.makeTensorInfo(l,"float32",u.imag),h=n.makeTensorInfo([],"float32",vg(a,"float32")),f=RL({inputs:{x:h},backend:n}),d=lB.kernelFunc({inputs:{a:c,b:h},backend:n}),m=lB.kernelFunc({inputs:{a:p,b:f},backend:n}),v=n.data.get(d.dataId).values,g=n.data.get(m.dataId).values;return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(m),{real:v,imag:g}}return u}return vT(function(e,t,n){for(var r=new Float32Array(2*t),a=0;a<t;a++){for(var i=0,o=0,s=0;s<t;s++){var u=kT(a*s,t,n),l=bT(e,s);i+=l.real*u.real-l.imag*u.imag,o+=l.real*u.imag+l.imag*u.real}n&&(i/=t,o/=t),xT(r,i,o,a)}return r}(mT(o,s),a,t))}var hB={kernelName:"FFT",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.input,a=fv(r.shape),i=r.shape[r.shape.length-1],o=eP({inputs:{x:r},backend:n,attrs:{shape:[a/i,i]}}),s=cB(o,!1,n),u=eP({inputs:{x:s},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),u}};function fB(e){var t=e.backend,n=e.attrs,r=n.shape,a=n.value,i=n.dtype||_v(a),o=Nv(i,fv(r));return function(e,t,n){e.fill(t)}(o,a),t.makeTensorInfo(r,i,o)}var dB={kernelName:"Fill",backendName:"cpu",kernelFunc:fB};var mB={kernelName:"FlipLeftRight",backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs,n=(e.attrs,e.backend),r=t.image,a=n,i=kv(r.dtype,fv(r.shape)),o=r.shape,s=o[0],u=o[1],l=o[2],c=o[3],p=a.data.get(r.dataId).values,h=0;h<s;h++)for(var f=h*l*u*c,d=0;d<u;d++)for(var m=d*(l*c),v=0;v<l;v++)for(var g=v*c,y=0;y<c;y++){var b=[s,d,v,y][2],x=Math.round(l-b),w=f+m+g+y,k=p[w];if(x>=0&&x<l)k=p[f+m+x*c+y];i[w]=k}return{dataId:a.write(i,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},vB={kernelName:"FloorDiv",backendName:"cpu",kernelFunc:ML("FloorDiv",SL((function(e,t){return Math.floor(e/t)})),null,"int32")};var gB={kernelName:"FusedConv2D",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=t.bias,s=t.preluActivationWeights,u=r.strides,l=r.pad,c=r.dataFormat,p=r.dilations,h=r.dimRoundingMode,f=r.activation,d=r.leakyreluAlpha,m=_P({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:h}});if(o){var v=m;m=BL({inputs:{a:m,b:o},backend:n}),n.disposeIntermediateTensorInfo(v)}if(f){var g=m;m=$z(n,m,f,s,d),n.disposeIntermediateTensorInfo(g)}return m}};var yB={kernelName:"FusedDepthwiseConv2D",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=t.bias,s=t.preluActivationWeights,u=r.strides,l=r.pad,c=r.dataFormat,p=r.dilations,h=r.dimRoundingMode,f=r.activation,d=r.leakyreluAlpha,m=KP({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:p,dimRoundingMode:h}});if(o){var v=m;m=BL({inputs:{a:m,b:o},backend:n}),n.disposeIntermediateTensorInfo(v)}if(f){var g=m;m=$z(n,m,f,s,d),n.disposeIntermediateTensorInfo(g)}return m}};var bB={kernelName:"GatherNd",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.params,a=t.indices,i=fv(r.shape),o=a.shape,s=o[o.length-1],u=_b(r,a),l=u[0],c=u[1],p=u[2],h=u[3];if(0===c)return n.makeTensorInfo(l,r.dtype,[]);for(var f=nb([c,p],r.dtype),d=n.data.get(a.dataId).values,m=n.data.get(r.dataId).values,v=0;v<c;v++){for(var g=[],y=0,b=0;b<s;b++){var x=d[v*s+b];y+=x*h[b],g.push(x)}if(y<0||y>=i/p)throw new Error("Invalid indices: "+g+" does not index into "+r.shape);for(var w=0;w<p;w++)f.values[v*p+w]=m[y*p+w]}return n.makeTensorInfo(l,f.dtype,f.values)}};var xB={kernelName:"GatherV2",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.indices,o=r.axis,s=r.batchDims;xL([a,i],"gatherV2");var u=s;null==s&&(u=0);var l=fv(i.shape),c=TT(a,i,xv(o,a.shape)[0],u),p=eP({inputs:{x:a},backend:n,attrs:{shape:[c.batchSize,c.outerSize,c.dimSize,c.sliceSize]}}),h=eP({inputs:{x:i},backend:n,attrs:{shape:[c.batchSize,l/c.batchSize]}}),f=[c.batchSize,c.outerSize,l/c.batchSize,c.sliceSize],d=n.bufferSync(h),m=tz(n.bufferSync(p),d,f);return n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.makeTensorInfo(c.outputShape,m.dtype,m.values)}},wB={kernelName:"GreaterEqual",backendName:"cpu",kernelFunc:ML("GreaterEqual",SL((function(e,t){return e>=t?1:0})),null,"bool")};var kB={kernelName:"IFFT",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.input,a=fv(r.shape),i=r.shape[r.shape.length-1],o=eP({inputs:{x:r},backend:n,attrs:{shape:[a/i,i]}}),s=cB(o,!0,n),u=eP({inputs:{x:s},backend:n,attrs:{shape:r.shape}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),u}},NB={kernelName:"IsFinite",backendName:"cpu",kernelFunc:jL("IsFinite",(function(e){return Number.isFinite(e)?1:0}),"bool")},IB={kernelName:"IsInf",backendName:"cpu",kernelFunc:jL("IsInf",(function(e){return Math.abs(e)===1/0?1:0}),"bool")},SB={kernelName:"IsNan",backendName:"cpu",kernelFunc:jL("IsNan",(function(e){return Number.isNaN(e)?1:0}),"bool")},TB={kernelName:"LessEqual",backendName:"cpu",kernelFunc:ML("LessEqual",SL((function(e,t){return e<=t?1:0})),null,"bool")};var CB={kernelName:"LinSpace",backendName:"cpu",kernelFunc:function(e){var t=e.backend,n=e.attrs,r=oz(n.start,n.stop,n.num);return t.makeTensorInfo([r.length],"float32",r)}},EB={kernelName:"Log1p",backendName:"cpu",kernelFunc:jL("Log1p",(function(e){return Math.log1p(e)}))},RB={kernelName:"LogicalAnd",backendName:"cpu",kernelFunc:ML("LogicalAnd",SL((function(e,t){return e&&t})),null,"bool")},AB={kernelName:"LogicalNot",backendName:"cpu",kernelFunc:jL("LogicalNot",(function(e){return e?0:1}),"bool")},DB={kernelName:"LogicalOr",backendName:"cpu",kernelFunc:ML("LogicalOr",SL((function(e,t){return e||t})),null,"bool")};var FB={kernelName:"LRN",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.depthRadius,o=r.bias,s=r.alpha,u=r.beta;xL(a,"LRN");var l=a.shape[3],c=l-1,p=n.data.get(a.dataId).values,h=fv(a.shape),f=new Float32Array(h);function d(e){for(var t=e%l,n=e-t+Math.max(0,t-i),r=e-t+Math.min(t+i,c),a=0;n<=r;n++){var o=p[n];a+=o*o}return a}for(var m=0;m<h;m++){var v=d(m),g=p[m]*Math.pow(o+s*v,-u);f[m]=g}return n.makeTensorInfo(a.shape,a.dtype,f)}};var _B={kernelName:"LRNGrad",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.y,o=t.dy,s=r.depthRadius,u=r.bias,l=r.alpha,c=r.beta;xL(o,"LRNGrad");for(var p=fv(o.shape),h=o.shape[3],f=n.data.get(o.dataId).values,d=n.data.get(a.dataId).values,m=n.data.get(i.dataId).values,v=new Float32Array(p),g=p,y=0;y<g;y++){for(var b=y%h,x=y-b+Math.max(0,b-s),w=y-b+Math.min(h,b+s+1),k=0,N=x;N<w;N++)k+=Math.pow(d[N],2);k=l*k+u;for(var I=x;I<w;I++){var S=-2*l*c*d[I]*m[y]/k;y===I&&(S+=Math.pow(k,-c)),S*=f[y],v[I]+=S}}return n.makeTensorInfo(o.shape,a.dtype,v)}};function OB(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.reductionIndices,o=r.keepDims,s=n,u=a.shape,l=u.length,c=xv(i,u),p=c,h=Ik(p,l),f=s.data.get(a.dataId).values;if(null!=h){for(var d=new Array(l),m=0;m<d.length;m++)d[m]=u[h[m]];f=kz(f,u,a.dtype,h,d),p=Tk(p.length,l),u=d}xL(a,"max"),Nk("max",p,l);var v=wk(u,p),g=v[0],y=cz(f,fv(v[1]),g,a.dtype),b=s.write(y,g,a.dtype),x=g;o&&(x=kk(g,c));return{dataId:b,shape:x,dtype:a.dtype}}var MB={kernelName:"Max",backendName:"cpu",kernelFunc:OB};var LB={kernelName:"MaxPool",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;xL(a,"maxPool");var i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode;lv(Xx(o,1),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+o+" and dilations '1'"}));var l,c=Px(a.shape,i,o,1,s,u);if(1===c.filterWidth&&1===c.filterHeight&&dv(c.inShape,c.outShape))l=RL({inputs:{x:a},backend:n});else{var p=n.data.get(a.dataId).values,h=Lv(a.shape),f=gP(p,a.shape,a.dtype,h,c,"max");l=n.makeTensorInfo(c.outShape,a.dtype,f.values)}return l}};var zB={kernelName:"MaxPool3D",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode,l=r.dataFormat,c=r.dilations;xL(a,"maxPool3d");var p=c;null==p&&(p=[1,1,1]);var h=Bx(a.shape,i,o,p,s,u,l),f=bP(n.data.get(a.dataId).values,a.shape,a.dtype,Lv(a.shape),h,"max");return n.makeTensorInfo(f.shape,"float32",f.values)}};var PB={kernelName:"MaxPool3DGrad",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=r.filterSize,s=r.strides,u=r.pad,l=r.dilations,c=r.dimRoundingMode;xL([a,i],"maxPool3DGrad");for(var p=Bx(i.shape,o,s,l,u,c),h=function(e,t){for(var n=nb(t.outShape,"int32"),r=t.strideDepth,a=t.strideHeight,i=t.strideWidth,o=t.dilationDepth,s=t.dilationHeight,u=t.dilationWidth,l=t.effectiveFilterDepth,c=t.effectiveFilterHeight,p=t.effectiveFilterWidth,h=t.padInfo.front,f=t.padInfo.top,d=t.padInfo.left,m=0;m<t.batchSize;++m)for(var v=0;v<t.inChannels;++v)for(var g=0;g<t.outDepth;++g){for(var y=g*r-h,b=y;b<0;)b+=o;for(var x=Math.min(t.inDepth,l+y),w=0;w<t.outHeight;++w){for(var k=w*a-f,N=k;N<0;)N+=s;for(var I=Math.min(t.inHeight,c+k),S=0;S<t.outWidth;++S){for(var T=S*i-d,C=T;C<0;)C+=u;for(var E=Math.min(t.inWidth,p+T),R=Number.NEGATIVE_INFINITY,A=-1,D=b;D<x;D+=o)for(var F=D-y,_=N;_<I;_+=s)for(var O=_-k,M=C;M<E;M+=u){var L=M-T,z=e.get(m,D,_,M,v);z>=R&&(R=z,A=F*c*p+O*c+L)}n.set(A,m,g,w,S,v)}}}return n}(n.bufferSync(i),p),f=p.strideDepth,d=p.strideHeight,m=p.strideWidth,v=p.dilationDepth,g=p.dilationHeight,y=p.dilationWidth,b=p.effectiveFilterDepth,x=p.effectiveFilterHeight,w=p.effectiveFilterWidth,k=b-1-p.padInfo.front,N=w-1-p.padInfo.left,I=x-1-p.padInfo.top,S=nb(i.shape,"float32"),T=n.bufferSync(a),C=0;C<p.batchSize;++C)for(var E=0;E<p.inChannels;++E)for(var R=0;R<p.inDepth;++R)for(var A=0;A<p.inHeight;++A)for(var D=0;D<p.inWidth;++D){for(var F=R-k,_=A-I,O=D-N,M=0,L=0;L<b;L+=v){var z=(F+L)/f;if(!(z<0||z>=p.outDepth||Math.floor(z)!==z))for(var P=0;P<x;P+=g){var B=(_+P)/d;if(!(B<0||B>=p.outHeight||Math.floor(B)!==B))for(var W=0;W<w;W+=y){var V=(O+W)/m;if(!(V<0||V>=p.outWidth||Math.floor(V)!==V)){var U=b*x*w-1-h.get(C,z,B,V,E)===L*x*w+P*w+W?1:0;if(0!==U)M+=T.get(C,z,B,V,E)*U}}}}S.set(M,C,R,A,D,E)}return n.makeTensorInfo(S.shape,S.dtype,S.values)}};var BB={kernelName:"MaxPoolGrad",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=i;xL([i,t.output],"maxPoolGrad");for(var s=r.filterSize,u=r.strides,l=r.pad,c=r.dimRoundingMode,p=Px(o.shape,s,u,1,l,c),h=n.data.get(o.dataId).values,f=nb(p.outShape,o.dtype,yP(h,o.shape,o.dtype,p).values),d=p.strideHeight,m=p.strideWidth,v=p.dilationHeight,g=p.dilationWidth,y=p.effectiveFilterHeight,b=p.effectiveFilterWidth,x=b-1-p.padInfo.left,w=y-1-p.padInfo.top,k=nb(o.shape,"float32"),N=n.data.get(a.dataId).values,I=nb(a.shape,"float32",N),S=0;S<p.batchSize;++S)for(var T=0;T<p.inChannels;++T)for(var C=0;C<p.inHeight;++C)for(var E=0;E<p.inWidth;++E){for(var R=C-w,A=E-x,D=0,F=0;F<y;F+=v){var _=(R+F)/d;if(!(_<0||_>=p.outHeight||Math.floor(_)!==_))for(var O=0;O<b;O+=g){var M=(A+O)/m;if(!(M<0||M>=p.outWidth||Math.floor(M)!==M)){var L=y*b-1-f.get(S,_,M,T)===F*b+O?1:0;if(0!==L)D+=I.get(S,_,M,T)*L}}}k.set(D,S,C,E,T)}return n.makeTensorInfo(k.shape,k.dtype,k.values)}};var WB={kernelName:"MaxPoolWithArgmax",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,i=n.filterSize,o=n.strides,s=n.pad,u=n.includeBatchInIndex,l=r;xL(a,"MaxPoolWithArgmax");var c=l.data.get(a.dataId).values,p=Px(a.shape,i,o,[1,1],s),h=function(e,t,n,r,a){var i=gP(e,0,n,Lv(t),a,"max"),o=yP(e,t,n,a,!0,r);return[i.values,o.values]}(c,a.shape,a.dtype,u,p),f=h[0],d=h[1],m=l.write(f,p.outShape,a.dtype),v=l.write(d,p.outShape,a.dtype);return[{dataId:m,shape:p.outShape,dtype:a.dtype},{dataId:v,shape:p.outShape,dtype:"int32"}]}};function VB(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=a.axis,s=a.keepDims;xL(i,"sum");var u=(t="bool"===i.dtype?_L({inputs:{x:i},backend:r,attrs:{dtype:"int32"}}):RL({inputs:{x:i},backend:r})).shape.length,l=xv(o,t.shape),c=Ik(l,u),p=l,h=t;null!=c&&(h=Nz({inputs:{x:t},backend:r,attrs:{perm:c}}),p=Tk(p.length,u)),Nk("sum",p,h.shape.length);for(var f=wk(h.shape,p),d=f[0],m=f[1],v=EL(r,d,Wg(h.dtype,"int32")),g=fv(m),y=r.data.get(v.dataId).values,b=r.data.get(h.dataId).values,x=0;x<y.length;++x){for(var w=x*g,k=0,N=0;N<g;++N)k+=b[w+N];y[x]=k}if(s){var I=v;v=eP({inputs:{x:v},backend:r,attrs:{shape:kk(v.shape,l)}}),r.disposeIntermediateTensorInfo(I)}return r.disposeIntermediateTensorInfo(t),null!=c&&r.disposeIntermediateTensorInfo(h),v}var UB={kernelName:"Sum",backendName:"cpu",kernelFunc:VB};var GB={kernelName:"Mean",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims,s=xv(i,a.shape),u=fv(wk(a.shape,s)[1]),l=[],c=n.makeTensorInfo([],"float32",new Float32Array([u]));l.push(c);var p=_L({inputs:{x:a},backend:n,attrs:{dtype:"float32"}});l.push(p);var h=uB({inputs:{a:p,b:c},backend:n});l.push(h);var f=VB({inputs:{x:h},backend:n,attrs:{axis:i,keepDims:o}});return l.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),f}};var jB={kernelName:"Min",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims;xL(a,"min");var s=xv(i,a.shape),u=s,l=Ik(u,a.shape.length),c=a;null!=l&&(c=Nz({inputs:{x:a},backend:n,attrs:{perm:l}}),u=Tk(u.length,a.shape.length)),Nk("min",u,c.shape.length);for(var p=wk(c.shape,u),h=p[0],f=fv(p[1]),d=Bv(fv(h),c.dtype),m=n.data.get(c.dataId).values,v=0;v<d.length;++v){for(var g=v*f,y=m[g],b=0;b<f;++b){var x=m[g+b];x<y&&(y=x)}d[v]=y}null!=l&&n.disposeIntermediateTensorInfo(c);var w=n.makeTensorInfo(h,c.dtype,d);if(o){var k=eP({inputs:{x:w},backend:n,attrs:{shape:kk(h,s)}});return n.disposeIntermediateTensorInfo(w),k}return w}};var HB={kernelName:"MirrorPad",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.paddings,o=r.mode;xL(a,"mirrorPad");for(var s=i.map((function(e,t){return e[0]+a.shape[t]+e[1]})),u=i.map((function(e){return e[0]})),l=i.map((function(e,t){return e[0]+a.shape[t]})),c="reflect"===o?0:1,p=n.data.get(a.dataId).values,h=a.shape.length,f=Lv(a.shape),d=fv(s),m=s.length,v=Lv(s),g=kv(a.dtype,d),y=0;y<d;y++){for(var b=Gv(y,m,v),x=0;x<m;x++)b[x]<u[x]?b[x]=2*u[x]-b[x]-c:b[x]>=l[x]&&(b[x]=2*(l[x]-1)-b[x]+c);var w=Uv(b=b.map((function(e,t){return e-u[t]})),h,f);g[y]=p[w]}return{dataId:n.write(g,s,a.dtype),shape:s,dtype:a.dtype}}},qB=SL((function(e,t){var n=e%t;return e<0&&t<0||e>=0&&t>=0?n:(n+t)%t})),KB=ML(rg,qB),XB={kernelName:rg,backendName:"cpu",kernelFunc:KB};function YB(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.logits,i=r.dim,o=a.shape.length,s=i;if(-1===s&&(s=o-1),s!==o-1)throw Error("Softmax along a non-last dimension is not yet supported. Logits was rank "+o+" and dim was "+s);var u=xv([s],a.shape),l=OB({inputs:{x:a},backend:n,attrs:{reductionIndices:u,keepDims:!1}}),c=kk(l.shape,u),p=eP({inputs:{x:l},backend:n,attrs:{shape:c}}),h=zz({inputs:{a:a,b:p},backend:n}),f=YL({inputs:{x:h},backend:n}),d=VB({inputs:{x:f},backend:n,attrs:{axis:u,keepDims:!1}}),m=eP({inputs:{x:d},backend:n,attrs:{shape:c}}),v=uB({inputs:{a:f,b:m},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(m),v}var JB={kernelName:"Softmax",backendName:"cpu",kernelFunc:YB};var ZB={kernelName:"Multinomial",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.logits,i=r.numSamples,o=r.seed,s=r.normalized;xL(a,"multinomial");for(var u=s?a:YB({inputs:{logits:a},backend:n,attrs:{dim:-1}}),l=u.shape[0],c=u.shape[1],p=n.data.get(u.dataId).values,h=[l,i],f=Bv(fv(h),"int32"),d=0;d<l;++d){var m=d*c,v=new Float32Array(c-1);v[0]=p[m];for(var g=1;g<v.length;++g)v[g]=v[g-1]+p[m+g];for(var y=dN(o.toString()),b=d*i,x=0;x<i;++x){var w=y();f[b+x]=v.length;for(var k=0;k<v.length;k++)if(w<v[k]){f[b+x]=k;break}}}return s||n.disposeIntermediateTensorInfo(u),n.makeTensorInfo(h,"int32",f)}},QB=cS;var $B={kernelName:"NonMaxSuppressionV3",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold;xL(a,"NonMaxSuppression");var l=n.data.get(a.dataId).values,c=n.data.get(i.dataId).values,p=QB(l,c,o,s,u).selectedIndices;return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}},eW=pS;var tW={kernelName:"NonMaxSuppressionV4",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,l=r.padToMaxOutputSize;xL(a,"NonMaxSuppressionPadded");var c=n.data.get(a.dataId).values,p=n.data.get(i.dataId).values,h=eW(c,p,o,s,u,l),f=h.selectedIndices,d=h.validOutputs;return[n.makeTensorInfo([f.length],"int32",new Int32Array(f)),n.makeTensorInfo([],"int32",new Int32Array([d]))]}},nW=hS;var rW={kernelName:"NonMaxSuppressionV5",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,l=r.softNmsSigma;xL(a,"NonMaxSuppressionWithScore");var c=n.data.get(a.dataId).values,p=n.data.get(i.dataId).values,h=nW(c,p,o,s,u,l),f=h.selectedIndices,d=h.selectedScores;return[n.makeTensorInfo([f.length],"int32",new Int32Array(f)),n.makeTensorInfo([d.length],"float32",new Float32Array(d))]}};var aW={kernelName:"OneHot",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.indices,i=r.depth,o=r.onValue,s=r.offValue;xL(a,"oneHot");var u=fv(a.shape),l=new Float32Array(u*i);l.fill(s);for(var c=n.data.get(a.dataId).values,p=0;p<u;++p)c[p]>=0&&c[p]<i&&(l[p*i+c[p]]=o);return n.makeTensorInfo([].concat(a.shape,[i]),"int32",l)}};function iW(e){var t=e.inputs,n=e.backend,r=t.x;if("string"===r.dtype)throw new Error("zerosLike is not supported for string tensors");if("complex64"===r.dtype){var a=DL({inputs:{input:r},backend:n}),i=iW({inputs:{x:a},backend:n}),o=RP({inputs:{input:r},backend:n}),s=iW({inputs:{x:o},backend:n}),u=TL({inputs:{real:i,imag:s},backend:n});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),u}return fB({backend:n,attrs:{shape:r.shape,value:0,dtype:r.dtype}})}var oW={kernelName:"ZerosLike",backendName:"cpu",kernelFunc:iW};var sW={kernelName:"OnesLike",backendName:"cpu",kernelFunc:function e(t){var n=t.inputs,r=t.backend,a=n.x;if("string"===a.dtype)throw new Error("onesLike is not supported for string tensors");if("complex64"===a.dtype){var i=DL({inputs:{input:a},backend:r}),o=e({inputs:{x:i},backend:r}),s=RP({inputs:{input:a},backend:r}),u=iW({inputs:{x:s},backend:r}),l=TL({inputs:{real:o,imag:u},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(s),r.disposeIntermediateTensorInfo(u),l}return fB({backend:r,attrs:{shape:a.shape,value:1,dtype:a.dtype}})}};function uW(e){var t=e.inputs,n=e.backend,r=e.attrs.axis;if(1===t.length)return oB({inputs:{input:t[0]},backend:n,attrs:{dim:r}});var a=t[0].shape,i=t[0].dtype;t.forEach((function(e){cv(a,e.shape,"All tensors passed to stack must have matching shapes"),lv(i===e.dtype,(function(){return"All tensors passed to stack must have matching dtypes"}))}));var o=[],s=DP({inputs:t.map((function(e){var t=oB({inputs:{input:e},backend:n,attrs:{dim:r}});return o.push(t),t})),backend:n,attrs:{axis:r}});return o.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),s}var lW={kernelName:"Pack",backendName:"cpu",kernelFunc:uW};var cW={kernelName:"PadV2",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.paddings,o=r.constantValue;xL(a,"pad");var s=i.map((function(e,t){return e[0]+a.shape[t]+e[1]})),u=i.map((function(e){return e[0]})),l=n.data.get(a.dataId).values,c=fv(a.shape),p=a.shape.length,h=Lv(a.shape),f=fv(s),d=s.length,m=Lv(s),v=kv(a.dtype,f);0!==o&&v.fill(o);for(var g=0;g<c;g++){v[Uv(Gv(g,p,h).map((function(e,t){return e+u[t]})),d,m)]=l[g]}return{dataId:n.write(v,s,a.dtype),shape:s,dtype:a.dtype}}},pW=SL((function(e,t){return Math.pow(e,t)})),hW=ML(ag,pW),fW={kernelName:ag,backendName:"cpu",kernelFunc:hW};var dW={kernelName:"Range",backendName:"cpu",kernelFunc:function(e){var t=e.backend,n=e.attrs,r=n.start,a=n.stop,i=n.dtype,o=Cz(r,a,n.step,i);return t.makeTensorInfo([o.length],i,o)}},mW={kernelName:"Reciprocal",backendName:"cpu",kernelFunc:jL("Reciprocal",(function(e){return 1/e}))};var vW={kernelName:"ResizeBilinear",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=r.alignCorners,o=r.halfPixelCenters,s=r.size;xL(a,"resizeBilinear");for(var u=Lv(a.shape),l=s[0],c=s[1],p=a.shape,h=p[0],f=p[1],d=p[2],m=p[3],v=n.data.get(a.dataId).values,g=new Float32Array(fv([h,l,c,m])),y=[i&&l>1?f-1:f,i&&c>1?d-1:d],b=[i&&l>1?l-1:l,i&&c>1?c-1:c],x=0,w=y[0]/b[0],k=y[1]/b[1],N=0;N<h;N++)for(var I=0;I<l;I++){var S=void 0;S=o?w*(I+.5)-.5:w*I;for(var T=Math.max(0,Math.floor(S)),C=S-T,E=Math.min(f-1,Math.ceil(S)),R=N*u[0]+T*u[1],A=N*u[0]+E*u[1],D=0;D<c;D++){var F=void 0;F=o?k*(D+.5)-.5:k*D;for(var _=Math.max(0,Math.floor(F)),O=F-_,M=Math.min(d-1,Math.ceil(F)),L=R+_*u[2],z=A+_*u[2],P=R+M*u[2],B=A+M*u[2],W=0;W<m;W++){var V=v[L+W],U=v[z+W],G=V+(v[P+W]-V)*O,j=G+(U+(v[B+W]-U)*O-G)*C;g[x++]=j}}}return n.makeTensorInfo([h,l,c,m],"float32",g)}};var gW={kernelName:"ResizeBilinearGrad",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=t.dy,o=r.alignCorners;xL([i,a],"resizeBilinearGrad");for(var s=Lv(a.shape),u=a.shape,l=u[0],c=u[1],p=u[2],h=u[3],f=i.shape,d=f[1],m=f[2],v=new Float32Array(l*c*p*h),g=[o&&d>1?c-1:c,o&&m>1?p-1:p],y=[o&&d>1?d-1:d,o&&m>1?m-1:m],b=g[0]/y[0],x=g[1]/y[1],w=n.data.get(i.dataId).values,k=0,N=0;N<l;N++)for(var I=N*s[0],S=0;S<d;S++)for(var T=S*b,C=Math.floor(T),E=Math.min(Math.ceil(T),c-1),R=I+C*s[1],A=I+E*s[1],D=T-C,F=1-D,_=0;_<m;_++)for(var O=_*x,M=Math.floor(O),L=Math.min(Math.ceil(O),p-1),z=O-M,P=1-z,B=R+M*s[2],W=R+L*s[2],V=A+M*s[2],U=A+L*s[2],G=F*P,j=F*z,H=D*P,q=D*z,K=0;K<h;K++){var X=w[k++];v[B+K]+=X*G,v[W+K]+=X*j,v[V+K]+=X*H,v[U+K]+=X*q}return n.makeTensorInfo([l,p,c,h],"float32",v)}};var yW={kernelName:"ResizeNearestNeighbor",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=r.alignCorners,o=r.halfPixelCenters,s=r.size;xL(a,"resizeNearestNeighbor");for(var u=Lv(a.shape),l=s[0],c=s[1],p=a.shape,h=p[0],f=p[1],d=p[2],m=p[3],v=n.data.get(a.dataId).values,g=new Float32Array(h*l*c*m),y=[i&&l>1?f-1:f,i&&c>1?d-1:d],b=[i&&l>1?l-1:l,i&&c>1?c-1:c],x=y[0]/b[0],w=y[1]/b[1],k=0,N=0;N<h;N++)for(var I=N*u[0],S=0;S<l;S++){var T=o?x*(S+.5):x*S,C=Math.min(f-1,i?Math.round(T):Math.floor(T));o&&(C=Math.max(0,C));for(var E=I+C*u[1],R=0;R<c;R++){var A=o?w*(R+.5):w*R,D=Math.min(d-1,i?Math.round(A):Math.floor(A));o&&(D=Math.max(0,D));for(var F=E+D*u[2],_=0;_<m;_++){var O=v[F+_];g[k++]=O}}}return n.makeTensorInfo([h,l,c,m],a.dtype,g)}};var bW={kernelName:"ResizeNearestNeighborGrad",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=t.dy,o=r.alignCorners;xL([i,a],"resizeNearestNeighborGrad");for(var s=Lv(a.shape),u=Lv(i.shape),l=a.shape,c=l[0],p=l[1],h=l[2],f=l[3],d=i.shape,m=d[1],v=d[2],g=new Float32Array(c*p*h*f),y=n.data.get(i.dataId).values,b=[o&&m>1?p-1:p,o&&v>1?h-1:h],x=[o&&m>1?m-1:m,o&&v>1?v-1:v],w=b[0]/x[0],k=b[1]/x[1],N=1/w,I=1/k,S=2*Math.ceil(N)+2,T=2*Math.ceil(I)+2,C=0;C<c;C++)for(var E=C*s[0],R=0;R<p;R++)for(var A=E+R*s[1],D=Math.floor(R*N),F=Math.floor(D-S/2),_=0;_<h;_++)for(var O=A+_*s[2],M=Math.floor(_*I),L=Math.floor(M-T/2),z=0;z<f;z++){for(var P=0,B=0;B<S;B++){var W=B+F;if(!(W<0||W>=m)){var V=E+W*u[1],U=W*w;if(R===Math.min(p-1,o?Math.round(U):Math.floor(U)))for(var G=0;G<T;G++){var j=G+L;if(!(j<0||j>=v)){var H=V+j*u[2],q=j*k;_===Math.min(h-1,o?Math.round(q):Math.floor(q))&&(P+=y[H+z])}}}}g[O+z]=P}return n.makeTensorInfo(a.shape,a.dtype,g)}};var xW={kernelName:"Reverse",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.dims;xL(a,"reverse");var o=a.shape.length,s=xv(i,a.shape);if(0===o)return RL({inputs:{x:a},backend:n});for(var u=new Rg(a.shape,a.dtype),l=n.bufferSync(a),c=function(e){var t=u.indexToLoc(e),n=t.slice();s.forEach((function(e){return n[e]=a.shape[e]-1-n[e]})),u.set.apply(u,[l.get.apply(l,n)].concat(t))},p=0;p<u.size;p++)c(p);return n.makeTensorInfo(u.shape,u.dtype,u.values)}},wW={kernelName:"RotateWithOffset",backendName:"cpu",kernelFunc:function(e){for(var t=e.inputs,n=e.attrs,r=e.backend,a=t.image,i=n.radians,o=n.fillValue,s=n.center,u=r,l=kv(a.dtype,fv(a.shape)),c=a.shape,p=c[0],h=c[1],f=c[2],d=c[3],m=sT(s,h,f),v=m[0],g=m[1],y=Math.sin(i),b=Math.cos(i),x=u.data.get(a.dataId).values,w=0;w<p;w++)for(var k=w*f*h*d,N=0;N<h;N++)for(var I=N*(f*d),S=0;S<f;S++)for(var T=S*d,C=0;C<d;C++){var E=[p,N,S,C],R=E[2],A=E[1],D=(R-v)*b-(A-g)*y,F=(R-v)*y+(A-g)*b;D=Math.round(D+v),F=Math.round(F+g);var _=o;if("number"!=typeof o&&(_=3===C?255:o[C]),D>=0&&D<f&&F>=0&&F<h)_=x[k+F*(f*d)+D*d+C];l[k+I+T+C]=_}return{dataId:u.write(l,a.shape,a.dtype),shape:a.shape,dtype:a.dtype}}},kW={kernelName:"Round",backendName:"cpu",kernelFunc:jL("Round",(function(e){var t=Math.floor(e);return e-t<.5?Math.floor(e):e-t>.5?Math.ceil(e):t%2==0?t:t+1}))};function NW(e,t,n,r,a,i,o,s,u,l){var c=[r/a,a],p=e.values,h=t.values;if(0===r)return nb(n,t.dtype);var f=nb(c,t.dtype);f.values.fill(u);for(var d=0;d<i;d++){for(var m=[],v=0,g=0;g<o;g++){var y=p[d*o+g];m.push(y),v+=y*s[g]}if(v<0||v>=r/a)throw new Error("Invalid indices: "+m+" does not index into "+n);for(var b=0;b<a;b++)l?f.values[v*a+b]+=h[d*a+b]:f.values[v*a+b]=0===t.rank?h[0]:h[d*a+b]}return f}var IW={kernelName:"ScatterNd",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.indices,i=t.updates,o=r.shape,s=zb(0,a,o),u=s.sliceRank,l=s.numUpdates,c=s.sliceSize,p=s.strides,h=s.outputSize,f=NW(n.bufferSync(a),n.bufferSync(i),o,h,c,l,u,p,0,!0);return n.makeTensorInfo(o,f.dtype,f.values)}};var SW={kernelName:"Select",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.condition,a=t.t,i=t.e;xL([r,a,i],"select");for(var o=r.shape.length,s=n.data.get(r.dataId).values,u=n.data.get(a.dataId).values,l=n.data.get(i.dataId).values,c=Wg(a.dtype,i.dtype),p=Bv(fv(a.shape),c),h=0,f=0===o||o>1||1===a.shape.length?1:fv(a.shape.slice(1)),d=0;d<s.length;d++)for(var m=0;m<f;m++)1===s[d]?p[h++]=u[d]:p[h++]=l[d];return n.makeTensorInfo(a.shape,c,p)}},TW={kernelName:"Selu",backendName:"cpu",kernelFunc:jL("Selu",(function(e){return e>=0?1.0507009873554805*e:1.7580993408473768*(Math.exp(e)-1)}))},CW={kernelName:"Sigmoid",backendName:"cpu",kernelFunc:jL("Sigmoid",(function(e){return 1/(1+Math.exp(-e))}))},EW={kernelName:"Sign",backendName:"cpu",kernelFunc:jL("Sign",(function(e){return e<0?-1:e>0?1:0}))},RW=jL(ig,(function(e){return Math.sin(e)})),AW={kernelName:ig,backendName:"cpu",kernelFunc:RW},DW={kernelName:"Sinh",backendName:"cpu",kernelFunc:jL("Sinh",(function(e){return Math.sinh(e)}))},FW=Math.log(1.1920928955078125e-7)+2,_W={kernelName:"Softplus",backendName:"cpu",kernelFunc:jL("Softplus",(function(e){var t=e>-FW,n=e<FW,r=Math.exp(e);return n?r:t?e:Math.log(1+r)}))};var OW={kernelName:"SpaceToBatchND",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockShape,o=r.paddings;xL([a],"spaceToBatchND");var s=fv(i),u=[[0,0]];u.push.apply(u,o);for(var l=1+i.length;l<a.shape.length;++l)u.push([0,0]);var c=cW.kernelFunc({inputs:{x:a},backend:n,attrs:{paddings:u,constantValue:0}}),p=uT(c.shape,i,s,!1),h=lT(p.length,i.length,!1),f=cT(c.shape,i,s,!1),d=eP({inputs:{x:c},backend:n,attrs:{shape:p}}),m=Nz({inputs:{x:d},backend:n,attrs:{perm:h}}),v=eP({inputs:{x:m},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(m),v}};var MW={kernelName:"SparseToDense",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.sparseIndices,i=t.sparseValues,o=t.defaultValue,s=r.outputShape,u=zb(0,a,s),l=u.sliceRank,c=u.numUpdates,p=u.sliceSize,h=u.strides,f=u.outputSize,d=NW(n.bufferSync(a),n.bufferSync(i),s,f,p,c,l,h,n.data.get(o.dataId).values[0],!1);return n.makeTensorInfo(s,d.dtype,d.values)}};var LW={kernelName:"SplitV",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.numOrSizeSplits,o=xv(r.axis,a.shape)[0],s=NT(a,i,o),u=new Array(a.shape.length).fill(0),l=a.shape.slice();return s.map((function(e){var t=[].concat(l);t[o]=e;var r=Dz({inputs:{x:a},backend:n,attrs:{begin:u,size:t}});return u[o]+=e,r}))}},zW={kernelName:"Sqrt",backendName:"cpu",kernelFunc:jL("Sqrt",(function(e){return Math.sqrt(e)}))},PW={kernelName:"Square",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,a=n;xL(r,"square");for(var i=a.data.get(r.dataId).values,o=new Float32Array(i.length),s=0;s<i.length;++s){var u=i[s];o[s]=u*u}return{dataId:a.write(o,r.shape,r.dtype),shape:r.shape,dtype:r.dtype}}},BW={kernelName:"Step",backendName:"cpu",kernelFunc:jL("Step",(function(e,t){var n=t;return isNaN(e)?NaN:e>0?1:n.alpha}))};var WW={kernelName:"StridedSlice",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.begin,o=r.end,s=r.strides,u=r.beginMask,l=r.endMask,c=r.ellipsisMask,p=r.newAxisMask,h=r.shrinkAxisMask;xL(a,"stridedSlice");var f,d=ex(a.shape,i,o,s,u,l,c,p,h),m=d.nonStrided,v=d.$begin,g=d.$strides,y=d.size,b=d.newShape,x=d.outShape,w=eP({inputs:{x:a},backend:n,attrs:{shape:b}});if(m){var k=Dz({inputs:{x:w},backend:n,attrs:{begin:v,size:y}});f=eP({inputs:{x:k},backend:n,attrs:{shape:x}}),n.disposeIntermediateTensorInfo(k)}else if(x.some((function(e){return 0===e})))f=n.makeTensorInfo(x,a.dtype,[]);else{var N=Oz(x,n.bufferSync(w),g,v);f=n.makeTensorInfo(N.shape,N.dtype,N.values)}var I=eP({inputs:{x:f},backend:n,attrs:{shape:x}});return n.disposeIntermediateTensorInfo(w),n.disposeIntermediateTensorInfo(f),I}},VW=jL(sg,(function(e){return Math.tan(e)})),UW={kernelName:sg,backendName:"cpu",kernelFunc:VW},GW=jL("Tanh",(function(e){return Math.tanh(e)}));for(var jW=0,HW=[aP,IL,iP,oP,WL,sP,uP,lP,cP,pP,hP,fP,dP,mP,vP,xP,wP,kP,NP,rP,IP,SP,TP,OL,KL,CP,CL,EP,FP,MP,LP,OP,PP,BP,zP,VP,UP,GP,jP,HP,qP,XP,YP,JP,ZP,QP,eB,$P,lB,Gz,tB,rB,iB,JL,sB,QL,hB,dB,mB,ez,vB,gB,yB,bB,xB,rz,wB,AL,kB,AP,NB,IB,SB,Hz,iz,TB,CB,lz,EB,RB,AB,DB,FB,_B,hz,LB,zB,PB,BB,WB,MB,GB,jB,dz,HB,XB,ZB,yz,xz,$B,tW,rW,wz,aW,sW,lW,cW,fW,Xz,Tz,dW,FL,mW,Jz,Qz,tP,vW,gW,yW,bW,xW,wW,kW,Rz,IW,SW,TW,CW,EW,AW,DW,Fz,JB,_W,OW,MW,LW,zW,PW,_z,BW,WW,Pz,UB,UW,{kernelName:"Tanh",backendName:"cpu",kernelFunc:GW},{kernelName:"Tile",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.reps;xL(a,"tile");var o=Bz(n.bufferSync(a),i);return n.makeTensorInfo(o.shape,o.dtype,o.values)}},{kernelName:"TopK",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.k;r.sorted,xL(a,"topk");var o=Wz(n.data.get(a.dataId).values,a.shape,a.dtype,i),s=o[0],u=o[1];return[n.makeTensorInfo(s.shape,s.dtype,s.values),n.makeTensorInfo(u.shape,u.dtype,u.values)]}},Iz,{kernelName:"Unique",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=n.axis,i=t.x;xL(i,"unique");var o=Vz(r.data.get(i.dataId).values,a,i.shape,i.dtype),s=o.outputValues,u=o.outputShape,l=o.indices;return[r.makeTensorInfo(u,i.dtype,s),r.makeTensorInfo([l.length],"int32",l)]}},{kernelName:"Unpack",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.value,i=r.axis;i<0&&(i+=a.shape.length);for(var o=a.shape.length,s=a.shape[i],u=new Array(o-1),l=0,c=0;c<o;c++)c!==i&&(u[l++]=a.shape[c]);var p=new Array(o).fill(0),h=a.shape.slice();h[i]=1;for(var f=new Array(s),d=0;d<f.length;d++){p[i]=d;var m=Dz({inputs:{x:a},backend:n,attrs:{begin:p,size:h}});f[d]=eP({inputs:{x:m},backend:n,attrs:{shape:u}}),n.disposeIntermediateTensorInfo(m)}return f}},{kernelName:"UnsortedSegmentSum",backendName:"cpu",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.segmentIds,o=r.numSegments;xL(a,"unsortedSegmentSum");for(var s=[],u=[],l=a.shape.length-i.shape.length,c=i,p=0;p<l;++p){var h=oB({inputs:{input:c},backend:n,attrs:{dim:p+1}});c=h,u.push(h)}for(var f=0;f<o;++f){var d=vg(f,"int32"),m=n.makeTensorInfo([],"int32",d),v=nB({inputs:{a:m,b:c},backend:n}),g=_L({inputs:{x:v},backend:n,attrs:{dtype:"float32"}}),y=gz({inputs:{a:g,b:a},backend:n}),b=VB({inputs:{x:y},backend:n,attrs:{axis:0,keepDims:!1}});s.push(b),u.push(m),u.push(v),u.push(g),u.push(y),u.push(b)}var x=uW({inputs:s,backend:n,attrs:{axis:0}});return u.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),x}},oW];jW<HW.length;jW++){fg(HW[jW])}var qW,KW,XW,YW={},JW={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function ZW(e){if(!(e in YW)){var t=function(e){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");var t=function(e){if("undefined"!=typeof OffscreenCanvas&&2===e)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}(e);if(t.addEventListener("webglcontextlost",(function(t){t.preventDefault(),delete YW[e]}),!1),1===e)return t.getContext("webgl",JW)||t.getContext("experimental-webgl",JW);return t.getContext("webgl2",JW)}(e);if(null===t)return console.log("Could not get context for WebGL version",e),null;YW[e]=t}var n=YW[e];return n.isContextLost()?(delete YW[e],ZW(e)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),YW[e])}function QW(e,t){return[t,e]}function $W(e){var t=fv(e);return vv(Math.ceil(t/4))}function eV(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function tV(e,t){var n,r,a,i,o,s,u,l,c,p=e;return 2===Xv().getNumber("WEBGL_VERSION")?(n=p.R32F,r=p.R16F,a=p.RGBA16F,i=p.RGBA32F,o=p.RED,s=4,u=1,l=p.HALF_FLOAT,c=p.FLOAT):(n=e.RGBA,r=e.RGBA,a=e.RGBA,i=p.RGBA,o=e.RGBA,s=4,u=4,l=null!=t?t.HALF_FLOAT_OES:null,c=e.FLOAT),{internalFormatFloat:n,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:a,internalFormatPackedFloat:i,textureFormatFloat:o,downloadTextureFormat:e.RGBA,downloadUnpackNumChannels:s,defaultNumChannels:u,textureTypeHalfFloat:l,textureTypeFloat:c}}function nV(e,t){var n=t();return Xv().getBool("DEBUG")&&function(e){var t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+function(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"Unknown error code "+t}}(e,t))}(e),n}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(qW||(qW={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(KW||(KW={})),function(e){e[e.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",e[e.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",e[e.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",e[e.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",e[e.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(XW||(XW={}));function rV(e){return!!(Xv().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||5.96e-8<Math.abs(e)&&Math.abs(e)<65504)}function aV(e,t){return mV(e,(function(){return e.getExtension(t)}),'Extension "'+t+'" not supported on this browser.')}function iV(e,t){var n=mV(e,(function(){return e.createShader(e.FRAGMENT_SHADER)}),"Unable to create fragment WebGLShader.");if(nV(e,(function(){return e.shaderSource(n,t)})),nV(e,(function(){return e.compileShader(n)})),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw function(e,t){var n=uV.exec(t);if(null==n)return console.log("Couldn't parse line number in error: "+t),void console.log(e);for(var r=+n[1],a=e.split("\n"),i=a.length.toString().length+2,o=a.map((function(e,t){return gv((t+1).toString(),i)+e})),s=0,u=0;u<o.length;u++)s=Math.max(o[u].length,s);var l=o.slice(0,r-1),c=o.slice(r-1,r),p=o.slice(r);console.log(l.join("\n")),console.log(t.split("\n")[0]),console.log("%c "+gv(c[0],s),"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(p.join("\n"))}(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}var oV,sV,uV=/ERROR: [0-9]+:([0-9]+):/g;function lV(e,t){if(nV(e,(function(){return e.validateProgram(t)})),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function cV(e,t,n,r,a,i,o){var s=e.getAttribLocation(t,n);return-1!==s&&(nV(e,(function(){return e.bindBuffer(e.ARRAY_BUFFER,r)})),nV(e,(function(){return e.vertexAttribPointer(s,a,e.FLOAT,!1,i,o)})),nV(e,(function(){return e.enableVertexAttribArray(s)})),!0)}function pV(e,t,n,r){nV(e,(function(){return function(e,t,n){vV(e,n),nV(e,(function(){return e.activeTexture(e.TEXTURE0+n)})),nV(e,(function(){return e.bindTexture(e.TEXTURE_2D,t)}))}(e,t,r)})),nV(e,(function(){return e.uniform1i(n,r)}))}function hV(e,t,n){nV(e,(function(){return e.bindFramebuffer(e.FRAMEBUFFER,n)})),nV(e,(function(){return e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}))}function fV(e,t){nV(e,(function(){return e.bindFramebuffer(e.FRAMEBUFFER,t)})),nV(e,(function(){return e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)}))}function dV(e){var t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+function(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return"unknown error "+t}}(e,t))}function mV(e,t,n){var r=nV(e,(function(){return t()}));if(null==r)throw new Error(n);return r}function vV(e,t){var n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(r<e.TEXTURE0||r>n)throw new Error("textureUnit must be in "+("[gl.TEXTURE0, gl.TEXTURE"+n+"]")+".")}function gV(e,t){return void 0===t&&(t=2),fv(e.slice(0,e.length-t))}function yV(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function bV(e){var t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[gV(e)].concat(yV(e))),t}function xV(e){return e%2==0}function wV(e,t){if(dv(e=e.slice(-2),t=t.slice(-2)))return!0;if(!e.length||!t.length)return!0;if(0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){var n=e.slice(-1)[0],r=t.slice(-1)[0];if(n===r)return!0;if(xV(n)&&xV(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&xV(e[0])&&xV(t[0])}function kV(e,t){return null!=e.getExtension(t)}function NV(e){try{if(null!=ZW(e))return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function IV(e){if(0===e)return!1;var t=ZW(e);if(1!==e){if(kV(t,"EXT_color_buffer_float"))return SV(t);if(kV(t,"EXT_color_buffer_half_float")){var n=t.getExtension("EXT_color_buffer_half_float");return function(e,t){var n=tV(e,t),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r);e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);var a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);var i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(a),i}(t,n)}return!1}return!!kV(t,"OES_texture_float")&&(!!kV(t,"WEBGL_color_buffer_float")&&SV(t))}function SV(e){var t=tV(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);var r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);var a=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(r),a}function TV(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){null!=e&&lv("complex64"!==e.dtype,(function(){return t+" does not support complex64 tensors in the WebGL backend."}))}))}var CV=Xv();function EV(){var e,t,n,r,a,i,o,s,u,l;return 2===Xv().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",a="texture",i="outputColor",o="out vec4 outputColor;",s="\n      bool isnan_custom(float val) {\n        return (val > 0.0 || val < 0.0) ? false : val != 0.0;\n      }\n\n      bvec4 isnan_custom(vec4 val) {\n        return bvec4(isnan_custom(val.x),\n          isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n      }\n\n      #define isnan(value) isnan_custom(value)\n    ",u="",l="\n      #define round(value) newRound(value)\n      int newRound(float value) {\n        return int(floor(value + 0.5));\n      }\n\n      ivec4 newRound(vec4 value) {\n        return ivec4(floor(value + vec4(0.5)));\n      }\n    "):(e="",t="attribute",n="varying",r="varying",a="texture2D",i="gl_FragColor",o="",s="\n      #define isnan(value) isnan_custom(value)\n      bool isnan_custom(float val) {\n        return (val > 0. || val < 1. || val == 0.) ? false : true;\n      }\n      bvec4 isnan_custom(vec4 val) {\n        return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n      }\n    ",u="\n      uniform float INFINITY;\n\n      bool isinf(float val) {\n        return abs(val) == INFINITY;\n      }\n      bvec4 isinf(vec4 val) {\n        return equal(abs(val), vec4(INFINITY));\n      }\n    ",l="\n      int round(float value) {\n        return int(floor(value + 0.5));\n      }\n\n      ivec4 round(vec4 value) {\n        return ivec4(floor(value + vec4(0.5)));\n      }\n    "),{version:e,attribute:t,varyingVs:n,varyingFs:r,texture2D:a,output:i,defineOutput:o,defineSpecialNaN:s,defineSpecialInf:u,defineRound:l}}function RV(e,t,n){void 0===n&&(n="index");var r=Lv(t);return r.map((function(t,a){return"int "+e[a]+" = "+n+" / "+t+"; "+(a===r.length-1?"int "+e[a+1]+" = "+n+" - "+e[a]+" * "+t:"index -= "+e[a]+" * "+t)+";"})).join("")}function AV(e){var t=Lv(e).map((function(e){return e.toString()}));return"\n  int getFlatIndex(ivec3 coords) {\n    return coords.x * "+t[0]+" + coords.y * "+t[1]+" + coords.z;\n  }\n"}CV.registerFlag("HAS_WEBGL",(function(){return CV.getNumber("WEBGL_VERSION")>0})),CV.registerFlag("WEBGL_VERSION",(function(){return NV(2)?2:NV(1)?1:0})),CV.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(function(){return!1})),CV.registerFlag("WEBGL_BUFFER_SUPPORTED",(function(){return 2===CV.get("WEBGL_VERSION")})),CV.registerFlag("WEBGL_CPU_FORWARD",(function(){return!0})),CV.registerFlag("WEBGL_FORCE_F16_TEXTURES",(function(){return!1})),CV.registerFlag("WEBGL_PACK",(function(){return CV.getBool("HAS_WEBGL")})),CV.registerFlag("WEBGL_PACK_NORMALIZATION",(function(){return CV.getBool("WEBGL_PACK")})),CV.registerFlag("WEBGL_PACK_CLIP",(function(){return CV.getBool("WEBGL_PACK")})),CV.registerFlag("WEBGL_PACK_DEPTHWISECONV",(function(){return!1})),CV.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(function(){return CV.getBool("WEBGL_PACK")})),CV.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(function(){return CV.getBool("WEBGL_PACK")})),CV.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(function(){return CV.getBool("WEBGL_PACK")})),CV.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(function(){return CV.getBool("WEBGL_PACK")})),CV.registerFlag("WEBGL_PACK_REDUCE",(function(){return CV.getBool("WEBGL_PACK")})),CV.registerFlag("WEBGL_LAZILY_UNPACK",(function(){return CV.getBool("WEBGL_PACK")})),CV.registerFlag("WEBGL_CONV_IM2COL",(function(){return CV.getBool("WEBGL_PACK")})),CV.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(function(){return function(e){if(null==oV){var t=ZW(e);oV=t.getParameter(t.MAX_TEXTURE_SIZE)}return oV}(CV.getNumber("WEBGL_VERSION"))})),CV.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(function(){return function(e){if(null==sV){var t=ZW(e);sV=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,sV)}(CV.getNumber("WEBGL_VERSION"))})),CV.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(function(){var e=CV.getNumber("WEBGL_VERSION");return 0===e?0:function(e){if(0===e)return 0;var t=ZW(e);return kV(t,"EXT_disjoint_timer_query_webgl2")&&2===e?2:kV(t,"EXT_disjoint_timer_query")?1:0}(e)})),CV.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(function(){return CV.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!Qg()})),CV.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(function(){return function(e){if(0===e)return!1;var t=ZW(e);if(1===e){if(!kV(t,"OES_texture_float"))return!1}else if(!kV(t,"EXT_color_buffer_float"))return!1;return SV(t)}(CV.getNumber("WEBGL_VERSION"))})),CV.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(function(){return!CV.getBool("WEBGL_FORCE_F16_TEXTURES")&&CV.getBool("WEBGL_RENDER_FLOAT32_CAPABLE")})),CV.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(function(){return IV(CV.getNumber("WEBGL_VERSION"))})),CV.registerFlag("WEBGL_FENCE_API_ENABLED",(function(){return 2===(e=CV.getNumber("WEBGL_VERSION"))&&null!=ZW(e).fenceSync;var e})),CV.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(function(){return CV.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0})),CV.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(function(){return-1}),(function(e){if(e<0&&-1!==e)throw new Error("WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got "+e+".")}));var DV="\n  const float FLOAT_MAX = 1.70141184e38;\n  const float FLOAT_MIN = 1.17549435e-38;\n\n  lowp vec4 encode_float(highp float v) {\n    if (isnan(v)) {\n      return vec4(255, 255, 255, 255);\n    }\n\n    highp float av = abs(v);\n\n    if(av < FLOAT_MIN) {\n      return vec4(0.0, 0.0, 0.0, 0.0);\n    } else if(v > FLOAT_MAX) {\n      return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n    } else if(v < -FLOAT_MAX) {\n      return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;\n    }\n\n    highp vec4 c = vec4(0,0,0,0);\n\n    highp float e = floor(log2(av));\n    highp float m = exp2(fract(log2(av))) - 1.0;\n\n    c[2] = floor(128.0 * m);\n    m -= c[2] / 128.0;\n    c[1] = floor(32768.0 * m);\n    m -= c[1] / 32768.0;\n    c[0] = floor(8388608.0 * m);\n\n    highp float ebias = e + 127.0;\n    c[3] = floor(ebias / 2.0);\n    ebias -= c[3] * 2.0;\n    c[2] += floor(ebias) * 128.0;\n\n    c[3] += 128.0 * step(0.0, -v);\n\n    return c / 255.0;\n  }\n",FV=function(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=qW.DENSE;var t=$W(e),n=EV();this.outputShape=e,this.userCode="\n      ivec3 outCoordsFromFlatIndex(int index) {\n        "+RV(["r","c","d"],e)+"\n        return ivec3(r, c, d);\n      }\n\n      void main() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n          vec2("+t[0]+", "+t[1]+"));\n        int index = 4 * (resTexRC.x * "+t[1]+" + resTexRC.y);\n\n        vec4 result = vec4(0.);\n\n        for (int i=0; i<4; i++) {\n          int flatIndex = index + i;\n          ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n          result[i] = getA(rc.x, rc.y, rc.z);\n        }\n\n        "+n.output+" = result;\n      }\n    "},_V=function(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=qW.DENSE;var t=$W(e),n=EV();this.outputShape=e,this.userCode="\n      ivec3 outCoordsFromFlatIndex(int index) {\n        "+RV(["r","c","d"],e)+"\n        return ivec3(r, c, d);\n      }\n\n      void main() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n          vec2("+t[0]+", "+t[1]+"));\n        int index = 4 * (resTexRC.x * "+t[1]+" + resTexRC.y);\n\n        vec4 result = vec4(0.);\n\n        for (int i=0; i<4; i++) {\n          int flatIndex = index + i;\n          ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n          result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n        }\n\n        "+n.output+" = result;\n      }\n    "},OV=function(e){this.variableNames=["A"],this.outTexUsage=KW.DOWNLOAD;var t=EV();this.outputShape=e,this.userCode="\n      "+DV+"\n\n      void main() {\n        float x = getAAtOutCoords();\n        "+t.output+" = encode_float(x);\n      }\n    "},MV=function(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=KW.DOWNLOAD;var t=EV();this.outputShape=e,this.userCode="\n      "+DV+"\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n        float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n        "+t.output+" = encode_float(x);\n      }\n    "},LV=function(e,t,n){void 0===n&&(n=!1),this.variableNames=["A"];var r=EV(),a=t[0],i=t[1];this.outputShape=e;var o="result";n&&(o="floor(result * 255. + 0.5)"),this.userCode="\n      "+AV(e)+"\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n\n        int flatIndex = getFlatIndex(coords);\n        int offset = imod(flatIndex, 4);\n\n        flatIndex = idiv(flatIndex, 4, 1.);\n\n        int r = flatIndex / "+i+";\n        int c = imod(flatIndex, "+i+");\n        vec2 uv = (vec2(c, r) + halfCR) / vec2("+i+".0, "+a+".0);\n        vec4 values = "+r.texture2D+"(A, uv);\n\n        float result;\n\n        if(offset == 0) {\n          result = values[0];\n        } else if(offset == 1) {\n          result = values[1];\n        } else if(offset == 2) {\n          result = values[2];\n        } else {\n          result = values[3];\n        }\n\n        "+r.output+" = vec4("+o+", 0., 0., 0.);\n      }\n    "},zV=function(e,t,n){void 0===n&&(n=!1),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var r=EV(),a=t[0],i=t[1];this.outputShape=e;var o="",s="result";n&&(s="floor(result * 255. + 0.5)");for(var u=0;u<=1;u++)for(var l=0;l<=1;l++){var c=2*u+l;o+="\n          localCoords = coords;\n          if(localCoords[2] + "+l+" < "+e[2]+") {\n            localCoords[2] += "+l+";\n            if(localCoords[1] + "+u+" < "+e[1]+") {\n              localCoords[1] += "+u+";\n\n              flatIndex = getFlatIndex(localCoords);\n              offset = imod(flatIndex, 4);\n\n              flatIndex = idiv(flatIndex, 4, 1.);\n\n              r = flatIndex / "+i+";\n              c = imod(flatIndex, "+i+");\n              uv = (vec2(c, r) + halfCR) / vec2("+i+".0, "+a+".0);\n              values = "+r.texture2D+"(A, uv);\n\n              if(offset == 0) {\n                result["+c+"] = values[0];\n              } else if(offset == 1) {\n                result["+c+"] = values[1];\n              } else if(offset == 2) {\n                result["+c+"] = values[2];\n              } else {\n                result["+c+"] = values[3];\n              }\n            }\n          }\n        "}this.userCode="\n      "+AV(e)+"\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n\n        vec4 result = vec4(0.);\n        int flatIndex, r, c, offset;\n        ivec3 localCoords;\n        vec2 uv;\n        vec4 values;\n\n        "+o+"\n\n        "+r.output+" = "+s+";\n      }\n    "};function PV(e){var t=EV();return function(e,t){var n=mV(e,(function(){return e.createShader(e.VERTEX_SHADER)}),"Unable to create vertex WebGLShader.");if(nV(e,(function(){return e.shaderSource(n,t)})),nV(e,(function(){return e.compileShader(n)})),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}(e,t.version+"\n    precision highp float;\n    "+t.attribute+" vec3 clipSpacePos;\n    "+t.attribute+" vec2 uv;\n    "+t.varyingVs+" vec2 resultUV;\n\n    void main() {\n      gl_Position = vec4(clipSpacePos, 1);\n      resultUV = uv;\n    }")}function BV(e){return function(e,t){var n=mV(e,(function(){return e.createBuffer()}),"Unable to create WebGLBuffer");return nV(e,(function(){return e.bindBuffer(e.ARRAY_BUFFER,n)})),nV(e,(function(){return e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW)})),n}(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}function WV(e){return function(e,t){var n=mV(e,(function(){return e.createBuffer()}),"Unable to create WebGLBuffer");return nV(e,(function(){return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n)})),nV(e,(function(){return e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW)})),n}(e,new Uint16Array([0,1,2,2,1,3]))}function VV(e,t,n,r,a,i){!function(e,t){var n=Xv().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw new Error("Requested texture size "+("["+e+"x"+t+"]")+" is invalid.");if(e>n||t>n)throw new Error("Requested texture size "+("["+e+"x"+t+"]")+" greater than WebGL maximum on this browser / GPU "+("["+n+"x"+n+"]")+".")}(t,n);var o=function(e){return mV(e,(function(){return e.createTexture()}),"Unable to create WebGLTexture.")}(e),s=e.TEXTURE_2D;return nV(e,(function(){return e.bindTexture(s,o)})),nV(e,(function(){return e.texParameteri(s,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE)})),nV(e,(function(){return e.texParameteri(s,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)})),nV(e,(function(){return e.texParameteri(s,e.TEXTURE_MIN_FILTER,e.NEAREST)})),nV(e,(function(){return e.texParameteri(s,e.TEXTURE_MAG_FILTER,e.NEAREST)})),nV(e,(function(){return e.texImage2D(s,0,r,t,n,0,a,i,null)})),nV(e,(function(){return e.bindTexture(e.TEXTURE_2D,null)})),o}function UV(e){return e.internalFormatFloat}function GV(e){return e.internalFormatHalfFloat}function jV(e){return e.downloadTextureFormat}function HV(e){return e.internalFormatPackedFloat}function qV(e){return e.internalFormatPackedHalfFloat}function KV(e,t,n,r,a,i,o,s){var u=e,l=new Float32Array(function(e,t){var n=eV(e,t);return n[0]*n[1]*4}(i,o));return u.bindBuffer(u.PIXEL_PACK_BUFFER,t),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,l),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),l}var XV=function(){function e(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];var t=Xv().getNumber("WEBGL_VERSION");null!=e?(this.gl=e,function(e,t){YW[e]=t}(t,e)):this.gl=ZW(t);var n="WEBGL_color_buffer_float";if(1===Xv().getNumber("WEBGL_VERSION")){if(this.textureFloatExtension=aV(this.gl,"OES_texture_float"),kV(this.gl,"OES_texture_half_float"))this.textureHalfFloatExtension=aV(this.gl,"OES_texture_half_float");else if(Xv().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(n),kV(this.gl,"EXT_color_buffer_half_float"))this.colorBufferHalfFloatExtension=aV(this.gl,"EXT_color_buffer_half_float");else if(Xv().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(n="EXT_color_buffer_float",kV(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!kV(this.gl,"EXT_color_buffer_half_float"))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension("EXT_color_buffer_half_float")}this.vertexBuffer=BV(this.gl),this.indexBuffer=WV(this.gl),this.framebuffer=function(e){return mV(e,(function(){return e.createFramebuffer()}),"Unable to create WebGLFramebuffer.")}(this.gl),this.textureConfig=tV(this.gl,this.textureHalfFloatExtension)}var t=e.prototype;return t.dispose=function(){var e=this;if(!this.disposed){null!=this.program&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),null!=this.outputTexture&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture.  This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");var t=this.gl;nV(t,(function(){return t.finish()})),nV(t,(function(){return t.bindFramebuffer(t.FRAMEBUFFER,null)})),nV(t,(function(){return t.deleteFramebuffer(e.framebuffer)})),nV(t,(function(){return t.bindBuffer(t.ARRAY_BUFFER,null)})),nV(t,(function(){return t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)})),nV(t,(function(){return t.deleteBuffer(e.indexBuffer)})),this.disposed=!0}},t.createFloat32MatrixTexture=function(e,t){return this.throwIfDisposed(),function(e,t,n,r){var a=QW(t,n);return VV(e,a[0],a[1],UV(r),r.textureFormatFloat,e.FLOAT)}(this.gl,e,t,this.textureConfig)},t.createFloat16MatrixTexture=function(e,t){return this.throwIfDisposed(),function(e,t,n,r){var a=QW(t,n);return VV(e,a[0],a[1],GV(r),r.textureFormatFloat,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)},t.createUnsignedBytesMatrixTexture=function(e,t){return this.throwIfDisposed(),function(e,t,n,r){var a=QW(t,n);return VV(e,a[0],a[1],jV(r),e.RGBA,e.UNSIGNED_BYTE)}(this.gl,e,t,this.textureConfig)},t.uploadPixelDataToTexture=function(e,t){this.throwIfDisposed(),function(e,t,n){nV(e,(function(){return e.bindTexture(e.TEXTURE_2D,t)})),n.data instanceof Uint8Array?nV(e,(function(){return e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data)})):nV(e,(function(){return e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)})),nV(e,(function(){return e.bindTexture(e.TEXTURE_2D,null)}))}(this.gl,e,t)},t.uploadDenseMatrixToTexture=function(e,t,n,r){this.throwIfDisposed(),function(e,t,n,r,a,i){var o,s,u;nV(e,(function(){return e.bindTexture(e.TEXTURE_2D,t)})),a instanceof Uint8Array?(o=new Uint8Array(n*r*4),s=e.UNSIGNED_BYTE,u=e.RGBA):(o=new Float32Array(n*r*4),s=e.FLOAT,u=i.internalFormatPackedFloat),o.set(a),nV(e,(function(){return e.texImage2D(e.TEXTURE_2D,0,u,n,r,0,e.RGBA,s,o)})),nV(e,(function(){return e.bindTexture(e.TEXTURE_2D,null)}))}(this.gl,e,t,n,r,this.textureConfig)},t.createFloat16PackedMatrixTexture=function(e,t){return this.throwIfDisposed(),function(e,t,n,r){var a=eV(t,n);return VV(e,a[0],a[1],qV(r),e.RGBA,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)},t.createPackedMatrixTexture=function(e,t){return this.throwIfDisposed(),function(e,t,n,r){var a=eV(t,n);return VV(e,a[0],a[1],HV(r),e.RGBA,e.FLOAT)}(this.gl,e,t,this.textureConfig)},t.deleteMatrixTexture=function(e){var t=this;this.throwIfDisposed(),this.outputTexture===e&&(fV(this.gl,this.framebuffer),this.outputTexture=null),nV(this.gl,(function(){return t.gl.deleteTexture(e)}))},t.downloadByteEncodedFloatMatrixFromOutputTexture=function(e,t,n){var r=this;return this.downloadMatrixDriver(e,(function(){return function(e,t,n,r){var a=QW(t,n),i=a[0],o=a[1],s=new Uint8Array(t*n*4);return nV(e,(function(){return e.readPixels(0,0,i,o,r.downloadTextureFormat,e.UNSIGNED_BYTE,s)})),new Float32Array(s.buffer)}(r.gl,t,n,r.textureConfig)}))},t.downloadPackedMatrixFromBuffer=function(e,t,n,r,a,i){return KV(this.gl,e,0,0,0,a,i,this.textureConfig)},t.downloadFloat32MatrixFromBuffer=function(e,t){return function(e,t,n){var r=e,a=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}(this.gl,e,t)},t.createBufferFromTexture=function(e,t,n){this.bindTextureToFrameBuffer(e);var r=function(e,t,n,r){var a=e.createBuffer();nV(e,(function(){return e.bindBuffer(e.PIXEL_PACK_BUFFER,a)}));var i=16*t*n;return nV(e,(function(){return e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ)})),nV(e,(function(){return e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0)})),nV(e,(function(){return e.bindBuffer(e.PIXEL_PACK_BUFFER,null)})),a}(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r},t.createAndWaitForFence=function(){var e=this.createFence(this.gl);return this.pollFence(e)},t.createFence=function(e){var t,n,r=this;if(Xv().getBool("WEBGL_FENCE_API_ENABLED")){var a=e,i=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=function(){var e=a.clientWaitSync(i,0,0);return e===a.ALREADY_SIGNALED||e===a.CONDITION_SATISFIED},t=i}else Xv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=function(){return r.isQueryAvailable(t,Xv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}):n=function(){return!0};return{query:t,isFencePassed:n}},t.downloadMatrixFromPackedTexture=function(e,t,n){var r=this;return this.downloadMatrixDriver(e,(function(){return function(e,t,n){var r=new Float32Array(t*n*4);return nV(e,(function(){return e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r)})),r}(r.gl,t,n)}))},t.createProgram=function(e){this.throwIfDisposed();var t=this.gl,n=iV(t,e),r=PV(t),a=function(e){return mV(e,(function(){return e.createProgram()}),"Unable to create WebGLProgram.")}(t);return nV(t,(function(){return t.attachShader(a,r)})),nV(t,(function(){return t.attachShader(a,n)})),function(e,t){if(nV(e,(function(){return e.linkProgram(t)})),!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}(t,a),this.debug&&lV(t,a),this.vertexAttrsAreBound||(this.setProgram(a),this.vertexAttrsAreBound=function(e,t,n){return nV(e,(function(){return e.bindBuffer(e.ARRAY_BUFFER,n)})),cV(e,t,"clipSpacePos",n,3,20,0)&&cV(e,t,"uv",n,2,20,12)}(t,this.program,this.vertexBuffer)),a},t.deleteProgram=function(e){var t=this;this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&nV(this.gl,(function(){return t.gl.deleteProgram(e)}))},t.setProgram=function(e){var t=this;this.throwIfDisposed(),this.program=e,null!=this.program&&this.debug&&lV(this.gl,this.program),nV(this.gl,(function(){return t.gl.useProgram(e)}))},t.getUniformLocation=function(e,t,n){return void 0===n&&(n=!0),this.throwIfDisposed(),n?function(e,t,n){return mV(e,(function(){return e.getUniformLocation(t,n)}),'uniform "'+n+'" not present in program.')}(this.gl,e,t):function(e,t,n){return e.getUniformLocation(t,n)}(this.gl,e,t)},t.getAttributeLocation=function(e,t){var n=this;return this.throwIfDisposed(),nV(this.gl,(function(){return n.gl.getAttribLocation(e,t)}))},t.getUniformLocationNoThrow=function(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)},t.setInputMatrixTexture=function(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),pV(this.gl,e,t,n)},t.setOutputMatrixTexture=function(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)},t.setOutputPackedMatrixTexture=function(e,t,n){this.throwIfDisposed();var r=eV(t,n),a=r[0],i=r[1];this.setOutputMatrixTextureDriver(e,a,i)},t.setOutputMatrixWriteRegion=function(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)},t.setOutputPackedMatrixWriteRegion=function(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")},t.debugValidate=function(){null!=this.program&&lV(this.gl,this.program),dV(this.gl)},t.executeProgram=function(){this.throwIfDisposed(),this.throwIfNoProgram();var e=this.gl;this.debug&&this.debugValidate(),nV(e,(function(){return e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}))},t.blockUntilAllProgramsCompleted=function(){var e=this;this.throwIfDisposed(),nV(this.gl,(function(){return e.gl.finish()}))},t.getQueryTimerExtension=function(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=aV(this.gl,2===Xv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension},t.getQueryTimerExtensionWebGL2=function(){return this.getQueryTimerExtension()},t.getQueryTimerExtensionWebGL1=function(){return this.getQueryTimerExtension()},t.beginQuery=function(){if(2===Xv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}var r=this.getQueryTimerExtensionWebGL1(),a=r.createQueryEXT();return r.beginQueryEXT(r.TIME_ELAPSED_EXT,a),a},t.endQuery=function(){if(2!==Xv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}else{var t=this.gl,n=this.getQueryTimerExtensionWebGL2();t.endQuery(n.TIME_ELAPSED_EXT)}},t.waitForQueryAndGetTime=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,yv((function(){return n.disposed||n.isQueryAvailable(t,Xv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}));case 2:return e.abrupt("return",this.getQueryTime(t,Xv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")));case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getQueryTime=function(e,t){if(0===t)return null;if(2===t){var n=this.gl;return n.getQueryParameter(e,n.QUERY_RESULT)/1e6}var r=this.getQueryTimerExtensionWebGL1();return r.getQueryObjectEXT(e,r.QUERY_RESULT_EXT)/1e6},t.isQueryAvailable=function(e,t){if(0===t)return!0;if(2===t){var n=this.gl,r=this.getQueryTimerExtensionWebGL2(),a=n.getQueryParameter(e,n.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),a&&!this.disjoint}var i=this.getQueryTimerExtensionWebGL1(),o=i.getQueryObjectEXT(e,i.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(i.GPU_DISJOINT_EXT)),o&&!this.disjoint},t.pollFence=function(e){var t=this;return new Promise((function(n){t.addItemToPoll((function(){return e.isFencePassed()}),(function(){return n()}))}))},t.pollItems=function(){for(var e=function(e){for(var t=0;t<e.length;++t){if(!e[t]())break}return t-1}(this.itemsToPoll.map((function(e){return e.isDoneFn}))),t=0;t<=e;++t){(0,this.itemsToPoll[t].resolveFn)()}this.itemsToPoll=this.itemsToPoll.slice(e+1)},t.addItemToPoll=function(e,t){var n=this;this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1||yv((function(){return n.pollItems(),0===n.itemsToPoll.length}))},t.bindTextureToFrameBuffer=function(e){this.throwIfDisposed(),hV(this.gl,e,this.framebuffer),this.debug&&dV(this.gl)},t.unbindTextureToFrameBuffer=function(){null!=this.outputTexture?(hV(this.gl,this.outputTexture,this.framebuffer),this.debug&&dV(this.gl)):fV(this.gl,this.framebuffer)},t.downloadMatrixDriver=function(e,t){this.bindTextureToFrameBuffer(e);var n=t();return this.unbindTextureToFrameBuffer(),n},t.setOutputMatrixTextureDriver=function(e,t,n){this.throwIfDisposed();var r=this.gl;hV(r,e,this.framebuffer),this.debug&&dV(r),this.outputTexture=e,nV(r,(function(){return r.viewport(0,0,t,n)})),nV(r,(function(){return r.scissor(0,0,t,n)}))},t.setOutputMatrixWriteRegionDriver=function(e,t,n,r){var a=this;this.throwIfDisposed(),nV(this.gl,(function(){return a.gl.scissor(e,t,n,r)}))},t.throwIfDisposed=function(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")},t.throwIfNoProgram=function(){if(null==this.program)throw new Error("No GPU program is currently set.")},Hm(e,[{key:"debug",get:function(){return Xv().getBool("DEBUG")}}]),e}();var YV=Fw;function JV(e,t,n,r){var a=[];e.forEach((function(e){var t=fv(e.shapeInfo.logicalShape);e.shapeInfo.isUniform?a.push("uniform float "+e.name+(t>1?"["+t+"]":"")+";"):(a.push("uniform sampler2D "+e.name+";"),a.push("uniform int offset"+e.name+";"))}));var i,o,s=a.join("\n"),u=e.map((function(e){return function(e,t,n){void 0===n&&(n=!1);var r="";r+=n?QV(e):ZV(e);var a=e.shapeInfo.logicalShape,i=t.logicalShape;a.length<=i.length&&(r+=n?function(e,t){var n,r=e.name,a=r.charAt(0).toUpperCase()+r.slice(1),i="get"+a+"AtOutCoords",o=e.shapeInfo.logicalShape.length,s=t.logicalShape.length,u=YV(e.shapeInfo.logicalShape,t.logicalShape),l=iU(s),c=s-o,p=["x","y","z","w","u","v"];n=0===o?"":s<2&&u.length>=1?"coords = 0;":u.map((function(e){return"coords."+p[e+c]+" = 0;"})).join("\n");var h="";h=s<2&&o>0?"coords":e.shapeInfo.logicalShape.map((function(e,t){return"coords."+p[t+c]})).join(", ");var f="return outputValue;",d=1===fv(e.shapeInfo.logicalShape),m=1===fv(t.logicalShape);if(1!==o||d||m){if(d&&!m)f=1===s?"\n        return vec4(outputValue.x, outputValue.x, 0., 0.);\n      ":"\n        return vec4(outputValue.x);\n      ";else if(u.length){var v=o-2,g=o-1;u.indexOf(v)>-1&&u.indexOf(g)>-1?f="return vec4(outputValue.x);":u.indexOf(v)>-1?f="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":u.indexOf(g)>-1&&(f="return vec4(outputValue.xx, outputValue.zz);")}}else f="\n      return vec4(outputValue.xy, outputValue.xy);\n    ";return"\n    vec4 "+i+"() {\n      "+l+" coords = getOutputCoords();\n      "+n+"\n      vec4 outputValue = get"+a+"("+h+");\n      "+f+"\n    }\n  "}(e,t):function(e,t){var n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=t.texShape,o=e.shapeInfo.texShape,s=e.shapeInfo.logicalShape.length,u=t.logicalShape.length;if(!e.shapeInfo.isUniform&&s===u&&null==e.shapeInfo.flatOffset&&dv(o,i))return"\n      float "+a+"() {\n        return sampleTexture("+n+", resultUV);\n      }\n    ";var l,c=iU(u),p=YV(e.shapeInfo.logicalShape,t.logicalShape),h=u-s,f=["x","y","z","w","u","v"];l=0===s?"":u<2&&p.length>=1?"coords = 0;":p.map((function(e){return"coords."+f[e+h]+" = 0;"})).join("\n");var d="";d=u<2&&s>0?"coords":e.shapeInfo.logicalShape.map((function(e,t){return"coords."+f[t+h]})).join(", ");return"\n    float "+a+"() {\n      "+c+" coords = getOutputCoords();\n      "+l+"\n      return get"+r+"("+d+");\n    }\n  "}(e,t));return r}(e,t,r)})).join("\n"),l=t.texShape,c=EV(),p=function(e){return"\n    float sampleTexture(sampler2D textureSampler, vec2 uv) {\n      return "+e.texture2D+"(textureSampler, uv).r;\n    }\n  "}(c),h=function(e){return e.version+"\n    precision highp float;\n    precision highp int;\n    precision highp sampler2D;\n    "+e.varyingFs+" vec2 resultUV;\n    "+e.defineOutput+"\n    const vec2 halfCR = vec2(0.5, 0.5);\n\n    struct ivec5\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n    };\n\n    struct ivec6\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n      int v;\n    };\n\n    uniform float NAN;\n    "+e.defineSpecialNaN+"\n    "+e.defineSpecialInf+"\n    "+e.defineRound+"\n\n    int imod(int x, int y) {\n      return x - y * (x / y);\n    }\n\n    int idiv(int a, int b, float sign) {\n      int res = a / b;\n      int mod = imod(a, b);\n      if (sign < 0. && mod != 0) {\n        res -= 1;\n      }\n      return res;\n    }\n\n    //Based on the work of Dave Hoskins\n    //https://www.shadertoy.com/view/4djSRW\n    #define HASHSCALE1 443.8975\n    float random(float seed){\n      vec2 p = resultUV * seed;\n      vec3 p3  = fract(vec3(p.xyx) * HASHSCALE1);\n      p3 += dot(p3, p3.yzx + 19.19);\n      return fract((p3.x + p3.y) * p3.z);\n    }\n\n    "+$V+"\n    "+eU+"\n    "+tU+"\n  "}(c);return t.isPacked?(i=function(e,t){switch(e.length){case 0:return"\n    int getOutputCoords() {\n      return 0;\n    }\n  ";case 1:return function(e,t){var n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(1===n[0])return"\n      int getOutputCoords() {\n        return 2 * int(resultUV.x * "+n[1]+".0);\n      }\n    ";if(1===n[1])return"\n      int getOutputCoords() {\n        return 2 * int(resultUV.y * "+n[0]+".0);\n      }\n    ";return"\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n      return 2 * (resTexRC.x * "+n[1]+" + resTexRC.y);\n    }\n  "}(0,t);case 2:return function(e,t){var n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(dv(e,t))return"\n      ivec2 getOutputCoords() {\n        return 2 * ivec2(resultUV.yx * vec2("+n[0]+", "+n[1]+"));\n      }\n    ";var r=Math.ceil(e[1]/2);return"\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n\n      int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n      int r = 2 * (index / "+r+");\n      int c = imod(index, "+r+") * 2;\n\n      return ivec2(r, c);\n    }\n  "}(e,t);case 3:return n=e,r=t,a=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],i=Math.ceil(n[2]/2),o=i*Math.ceil(n[1]/2),"\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+a[0]+", "+a[1]+"));\n      int index = resTexRC.x * "+a[1]+" + resTexRC.y;\n\n      int b = index / "+o+";\n      index -= b * "+o+";\n\n      int r = 2 * (index / "+i+");\n      int c = imod(index, "+i+") * 2;\n\n      return ivec3(b, r, c);\n    }\n  ";default:return function(e,t){for(var n=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],r=Math.ceil(e[e.length-1]/2),a=r*Math.ceil(e[e.length-2]/2),i=a,o="",s="b, r, c",u=2;u<e.length-1;u++)i*=e[e.length-u-1],o="\n      int b"+u+" = index / "+i+";\n      index -= b"+u+" * "+i+";\n    "+o,s="b"+u+", "+s;return"\n    ivec"+e.length+" getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n      int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n\n      "+o+"\n\n      int b = index / "+a+";\n      index -= b * "+a+";\n\n      int r = 2 * (index / "+r+");\n      int c = imod(index, "+r+") * 2;\n\n      return ivec"+e.length+"("+s+");\n    }\n  "}(e,t)}var n,r,a,i,o}(t.logicalShape,l),o=function(e){return"\n    void setOutput(vec4 val) {\n      "+e.output+" = val;\n    }\n  "}(c)):(i=function(e,t){switch(e.length){case 0:return"\n    int getOutputCoords() {\n      return 0;\n    }\n  ";case 1:return function(e,t){if(1===t[0])return"\n      int getOutputCoords() {\n        return int(resultUV.x * "+t[1]+".0);\n      }\n    ";if(1===t[1])return"\n      int getOutputCoords() {\n        return int(resultUV.y * "+t[0]+".0);\n      }\n    ";return"\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+t[0]+", "+t[1]+"));\n      return resTexRC.x * "+t[1]+" + resTexRC.y;\n    }\n  "}(0,t);case 2:return function(e,t){if(dv(e,t))return"\n      ivec2 getOutputCoords() {\n        return ivec2(resultUV.yx * vec2("+t[0]+", "+t[1]+"));\n      }\n    ";if(1===e[1])return"\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2("+t[0]+", "+t[1]+"));\n        int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n        return ivec2(index, 0);\n      }\n    ";if(1===e[0])return"\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2("+t[0]+", "+t[1]+"));\n        int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n        return ivec2(0, index);\n      }\n    ";return"\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+t[0]+", "+t[1]+"));\n      int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n      int r = index / "+e[1]+";\n      int c = index - r * "+e[1]+";\n      return ivec2(r, c);\n    }\n  "}(e,t);case 3:return n=t,r=RV(["r","c","d"],e),"\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n      int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n      "+r+"\n      return ivec3(r, c, d);\n    }\n  ";case 4:return function(e,t){var n=RV(["r","c","d","d2"],e);return"\n    ivec4 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n        vec2("+t[0]+", "+t[1]+"));\n      int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n      "+n+"\n      return ivec4(r, c, d, d2);\n    }\n  "}(e,t);case 5:return function(e,t){var n=RV(["r","c","d","d2","d3"],e);return"\n    ivec5 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx * vec2("+t[0]+",\n                             "+t[1]+"));\n\n      int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n\n      "+n+"\n\n      ivec5 outShape = ivec5(r, c, d, d2, d3);\n      return outShape;\n    }\n  "}(e,t);case 6:return function(e,t){var n=RV(["r","c","d","d2","d3","d4"],e);return"\n    ivec6 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n        vec2("+t[0]+", "+t[1]+"));\n      int index = resTexRC.x * "+t[1]+" + resTexRC.y;\n\n      "+n+"\n\n      ivec6 result = ivec6(r, c, d, d2, d3, d4);\n      return result;\n    }\n  "}(e,t);default:throw new Error(e.length+"-D output sampling is not yet supported")}var n,r}(t.logicalShape,l),o=function(e){return"\n    void setOutput(float val) {\n      "+e.output+" = vec4(val, 0, 0, 0);\n    }\n  "}(c)),r&&(h+=nU),[h,p,o,s,i,u,n].join("\n")}function ZV(e){var t=e.shapeInfo.logicalShape;switch(t.length){case 0:return function(e){var t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return"float "+n+"() {return "+t+";}";var r=e.shapeInfo.texShape,a=r[0],i=r[1];if(1===a&&1===i)return"\n      float "+n+"() {\n        return sampleTexture("+t+", halfCR);\n      }\n    ";var o=e.shapeInfo.texShape,s=o[0],u=o[1],l=rU(t);return"\n    float "+n+"() {\n      vec2 uv = uvFromFlat("+s+", "+u+", "+l+");\n      return sampleTexture("+t+", uv);\n    }\n  "}(e);case 1:return function(e){var t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1);if(e.shapeInfo.isUniform)return"\n      float "+n+"(int index) {\n        "+aU(e)+"\n      }\n    ";var r=e.shapeInfo.texShape,a=r[0],i=r[1];if(1===i&&1===a)return"\n      float "+n+"(int index) {\n        return sampleTexture("+t+", halfCR);\n      }\n    ";var o=rU(t);if(1===i)return"\n      float "+n+"(int index) {\n        vec2 uv = vec2(0.5, (float(index + "+o+") + 0.5) / "+a+".0);\n        return sampleTexture("+t+", uv);\n      }\n    ";if(1===a)return"\n      float "+n+"(int index) {\n        vec2 uv = vec2((float(index + "+o+") + 0.5) / "+i+".0, 0.5);\n        return sampleTexture("+t+", uv);\n      }\n    ";return"\n    float "+n+"(int index) {\n      vec2 uv = uvFromFlat("+a+", "+i+", index + "+o+");\n      return sampleTexture("+t+", uv);\n    }\n  "}(e);case 2:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e.shapeInfo.texShape;if(null!=a&&dv(t,a)){var i=a[0],o=a[1];return"\n    float "+r+"(int row, int col) {\n      vec2 uv = (vec2(col, row) + halfCR) / vec2("+o+".0, "+i+".0);\n      return sampleTexture("+n+", uv);\n    }\n  "}var s=wv(t),u=s.newShape,l=s.keptDims,c=u;if(c.length<t.length){var p=oU(e,c);return"\n      "+ZV(p)+"\n      float "+r+"(int row, int col) {\n        return "+r+"("+sU(["row","col"],l)+");\n      }\n    "}if(e.shapeInfo.isUniform)return"\n      float "+r+"(int row, int col) {\n        int index = round(dot(vec2(row, col), vec2("+t[1]+", 1)));\n        "+aU(e)+"\n      }\n    ";var h=a[0],f=a[1],d=rU(n);if(1===f)return"\n    float "+r+"(int row, int col) {\n      float index = dot(vec3(row, col, "+d+"), vec3("+t[1]+", 1, 1));\n      vec2 uv = vec2(0.5, (index + 0.5) / "+h+".0);\n      return sampleTexture("+n+", uv);\n    }\n  ";if(1===h)return"\n    float "+r+"(int row, int col) {\n      float index = dot(vec3(row, col, "+d+"), vec3("+t[1]+", 1, 1));\n      vec2 uv = vec2((index + 0.5) / "+f+".0, 0.5);\n      return sampleTexture("+n+", uv);\n    }\n  ";return"\n  float "+r+"(int row, int col) {\n    // Explicitly use integer operations as dot() only works on floats.\n    int index = row * "+t[1]+" + col + "+d+";\n    vec2 uv = uvFromFlat("+h+", "+f+", index);\n    return sampleTexture("+n+", uv);\n  }\n"}(e);case 3:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t[1]*t[2],i=t[2],o=wv(t),s=o.newShape,u=o.keptDims,l=s;if(l.length<t.length){var c=oU(e,l);return"\n        "+ZV(c)+"\n        float "+r+"(int row, int col, int depth) {\n          return "+r+"("+sU(["row","col","depth"],u)+");\n        }\n      "}if(e.shapeInfo.isUniform)return"\n      float "+r+"(int row, int col, int depth) {\n        int index = round(dot(vec3(row, col, depth),\n                          vec3("+a+", "+i+", 1)));\n        "+aU(e)+"\n      }\n    ";var p=e.shapeInfo.texShape,h=p[0],f=p[1],d=e.shapeInfo.flatOffset;if(f===a&&null==d)return"\n        float "+r+"(int row, int col, int depth) {\n          float texR = float(row);\n          float texC = dot(vec2(col, depth), vec2("+i+", 1));\n          vec2 uv = (vec2(texC, texR) + halfCR) /\n                     vec2("+f+".0, "+h+".0);\n          return sampleTexture("+n+", uv);\n        }\n      ";if(f===i&&null==d)return"\n    float "+r+"(int row, int col, int depth) {\n      float texR = dot(vec2(row, col), vec2("+t[1]+", 1));\n      float texC = float(depth);\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+f+".0, "+h+".0);\n      return sampleTexture("+n+", uv);\n    }\n  ";var m=rU(n);return"\n      float "+r+"(int row, int col, int depth) {\n        // Explicitly use integer operations as dot() only works on floats.\n        int index = row * "+a+" + col * "+i+" + depth + "+m+";\n        vec2 uv = uvFromFlat("+h+", "+f+", index);\n        return sampleTexture("+n+", uv);\n      }\n  "}(e);case 4:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t[3],i=t[2]*a,o=t[1]*i,s=wv(t),u=s.newShape,l=s.keptDims;if(u.length<t.length){var c=oU(e,u);return"\n      "+ZV(c)+"\n      float "+r+"(int row, int col, int depth, int depth2) {\n        return "+r+"("+sU(["row","col","depth","depth2"],l)+");\n      }\n    "}if(e.shapeInfo.isUniform)return"\n      float "+r+"(int row, int col, int depth, int depth2) {\n        int index = round(dot(vec4(row, col, depth, depth2),\n                          vec4("+o+", "+i+", "+a+", 1)));\n        "+aU(e)+"\n      }\n    ";var p=e.shapeInfo.flatOffset,h=e.shapeInfo.texShape,f=h[0],d=h[1];if(d===o&&null==p)return"\n      float "+r+"(int row, int col, int depth, int depth2) {\n        float texR = float(row);\n        float texC =\n            dot(vec3(col, depth, depth2),\n                vec3("+i+", "+a+", 1));\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2("+d+".0, "+f+".0);\n        return sampleTexture("+n+", uv);\n      }\n    ";if(d===a&&null==p)return"\n      float "+r+"(int row, int col, int depth, int depth2) {\n        float texR = dot(vec3(row, col, depth),\n                         vec3("+t[1]*t[2]+", "+t[2]+", 1));\n        float texC = float(depth2);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2("+d+".0, "+f+".0);\n        return sampleTexture("+n+", uv);\n      }\n    ";var m=rU(n);return"\n    float "+r+"(int row, int col, int depth, int depth2) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * "+o+" + col * "+i+" +\n          depth * "+a+" + depth2;\n      vec2 uv = uvFromFlat("+f+", "+d+", index + "+m+");\n      return sampleTexture("+n+", uv);\n    }\n  "}(e);case 5:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t[4],i=t[3]*a,o=t[2]*i,s=t[1]*o,u=wv(t),l=u.newShape,c=u.keptDims;if(l.length<t.length){var p=oU(e,l);return"\n      "+ZV(p)+"\n      float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n        return "+r+"("+sU(["row","col","depth","depth2","depth3"],c)+");\n      }\n    "}if(e.shapeInfo.isUniform)return"\n      float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n        float index = dot(\n          vec4(row, col, depth, depth2),\n          vec4("+s+", "+o+", "+i+", "+a+")) +\n          depth3;\n        "+aU(e)+"\n      }\n    ";var h=e.shapeInfo.flatOffset,f=e.shapeInfo.texShape,d=f[0],m=f[1];if(m===s&&null==h)return"\n      float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n        int texR = row;\n        float texC = dot(vec4(col, depth, depth2, depth3),\n                         vec4("+o+", "+i+", "+a+", 1));\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2("+m+".0, "+d+".0);\n        return sampleTexture("+n+", uv);\n      }\n    ";if(m===a&&null==h)return"\n      float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n        float texR = dot(\n          vec4(row, col, depth, depth2),\n          vec4("+t[1]*t[2]*t[3]+",\n               "+t[2]*t[3]+", "+t[3]+", 1));\n        int texC = depth3;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2("+m+".0, "+d+".0);\n        return sampleTexture("+n+", uv);\n      }\n    ";var v=rU(n);return"\n    float "+r+"(int row, int col, int depth, int depth2, int depth3) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * "+s+" + col * "+o+" + depth * "+i+" +\n          depth2 * "+a+" + depth3 + "+v+";\n      vec2 uv = uvFromFlat("+d+", "+m+", index);\n      return sampleTexture("+n+", uv);\n    }\n  "}(e);case 6:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=wv(t),i=a.newShape,o=a.keptDims;if(i.length<t.length){var s=oU(e,i);return"\n      "+ZV(s)+"\n      float "+r+"(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        return "+r+"("+sU(["row","col","depth","depth2","depth3","depth4"],o)+");\n      }\n    "}var u=t[5],l=t[4]*u,c=t[3]*l,p=t[2]*c,h=t[1]*p;if(e.shapeInfo.isUniform)return"\n      float "+r+"(int row, int col, int depth,\n                  int depth2, int depth3, int depth4) {\n        int index = round(dot(\n          vec4(row, col, depth, depth2),\n          vec4("+h+", "+p+", "+c+", "+l+")) +\n          dot(\n            vec2(depth3, depth4),\n            vec2("+u+", 1)));\n        "+aU(e)+"\n      }\n    ";var f=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,m=d[0],v=d[1];if(v===h&&null==f)return"\n      float "+r+"(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        int texR = row;\n        float texC = dot(vec4(col, depth, depth2, depth3),\n          vec4("+p+", "+c+", "+l+", "+u+")) +\n               float(depth4);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2("+v+".0, "+m+".0);\n        return sampleTexture("+n+", uv);\n      }\n    ";if(v===u&&null==f)return"\n      float "+r+"(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        float texR = dot(vec4(row, col, depth, depth2),\n          vec4("+t[1]*t[2]*t[3]*t[4]+",\n               "+t[2]*t[3]*t[4]+",\n               "+t[3]*t[4]+",\n               "+t[4]+")) + float(depth3);\n        int texC = depth4;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2("+v+".0, "+m+".0);\n        return sampleTexture("+n+", uv);\n      }\n    ";var g=rU(n);return"\n    float "+r+"(int row, int col, int depth,\n                  int depth2, int depth3, int depth4) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * "+h+" + col * "+p+" + depth * "+c+" +\n          depth2 * "+l+" + depth3 * "+u+" + depth4 + "+g+";\n      vec2 uv = uvFromFlat("+m+", "+v+", index);\n      return sampleTexture("+n+", uv);\n    }\n  "}(e);default:throw new Error(t.length+"-D input sampling is not yet supported")}}function QV(e){var t,n,r;switch(e.shapeInfo.logicalShape.length){case 0:return t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),r=EV(),"\n    vec4 "+n+"() {\n      return "+r.texture2D+"("+t+", halfCR);\n    }\n  ";case 1:return function(e){var t=e.name,n="get"+t.charAt(0).toUpperCase()+t.slice(1),r=e.shapeInfo.texShape,a=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],i=EV();return"\n    vec4 "+n+"(int index) {\n      vec2 uv = packedUVfrom1D(\n        "+a[0]+", "+a[1]+", index);\n      return "+i.texture2D+"("+t+", uv);\n    }\n  "}(e);case 2:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e.shapeInfo.texShape,i=a[0],o=a[1],s=EV();if(null!=a&&dv(t,a))return"\n      vec4 "+r+"(int row, int col) {\n        vec2 uv = (vec2(col, row) + halfCR) / vec2("+o+".0, "+i+".0);\n\n        return "+s.texture2D+"("+n+", uv);\n      }\n    ";var u=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)],l=Math.ceil(t[1]/2);return"\n    vec4 "+r+"(int row, int col) {\n      vec2 uv = packedUVfrom2D("+l+", "+u[0]+", "+u[1]+", row, col);\n      return "+s.texture2D+"("+n+", uv);\n    }\n  "}(e);case 3:return function(e){var t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e.shapeInfo.texShape,i=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];if(1===t[0]){var o=t.slice(1),s=oU(e,o);return"\n        "+QV(s)+"\n        vec4 "+r+"(int b, int row, int col) {\n          return "+r+"("+sU(["b","row","col"],[1,2])+");\n        }\n      "}var u=i[0],l=i[1],c=Math.ceil(t[2]/2),p=c*Math.ceil(t[1]/2),h=EV();return"\n    vec4 "+r+"(int b, int row, int col) {\n      vec2 uv = packedUVfrom3D(\n        "+u+", "+l+", "+p+", "+c+", b, row, col);\n      return "+h.texture2D+"("+n+", uv);\n    }\n  "}(e);default:return function(e){for(var t=e.shapeInfo.logicalShape,n=t.length,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=e.shapeInfo.texShape,o=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],s=o[0],u=o[1],l=Math.ceil(t[n-1]/2),c=l*Math.ceil(t[n-2]/2),p="int b, int row, int col",h="b * "+c+" + (row / 2) * "+l+" + (col / 2)",f=2;f<n-1;f++)p="int b"+f+", "+p,c*=t[n-f-1],h="b"+f+" * "+c+" + "+h;var d=EV();return"\n    vec4 "+a+"("+p+") {\n      int index = "+h+";\n      int texR = index / "+u+";\n      int texC = index - texR * "+u+";\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+u+", "+s+");\n      return "+d.texture2D+"("+r+", uv);\n    }\n  "}(e)}}var $V="\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n  int texR = index / texNumC;\n  int texC = index - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n  int texelIndex = index / 2;\n  int texR = texelIndex / texNumC;\n  int texC = texelIndex - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",eU="\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n  int texNumC, int row, int col) {\n  int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n  int texR = texelIndex / texNumC;\n  int texC = texelIndex - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",tU="\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n    int texelsInBatch, int texelsInLogicalRow, int b,\n    int row, int col) {\n  int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n  int texR = index / texNumC;\n  int texC = index - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",nU="\n  float getChannel(vec4 frag, vec2 innerDims) {\n    vec2 modCoord = mod(innerDims, 2.);\n    return modCoord.x == 0. ?\n      (modCoord.y == 0. ? frag.r : frag.g) :\n      (modCoord.y == 0. ? frag.b : frag.a);\n  }\n  float getChannel(vec4 frag, int dim) {\n    float modCoord = mod(float(dim), 2.);\n    return modCoord == 0. ? frag.r : frag.g;\n  }\n";function rU(e){return"offset"+e}function aU(e){var t=e.name,n=fv(e.shapeInfo.logicalShape);return n<2?"return "+t+";":"\n    for (int i = 0; i < "+n+"; i++) {\n      if (i == index) {\n        return "+t+"[i];\n      }\n    }\n  "}function iU(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";if(5===e)return"ivec5";if(6===e)return"ivec6";throw Error("GPU for rank "+e+" is not yet supported")}function oU(e,t){var n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function sU(e,t){return t.map((function(t){return e[t]})).join(", ")}function uU(e,t){if(e.length!==t.length)throw Error("Binary was compiled with "+e.length+" inputs, but was executed with "+t.length+" inputs");e.forEach((function(e,n){var r=e.logicalShape,a=t[n],i=a.shape;if(!dv(r,i))throw Error("Binary was compiled with different shapes than the current args. Shapes "+r+" and "+i+" must match");if(!e.isUniform||!a.isUniform){var o=e.texShape,s=a.isUniform?null:a.texData.texShape;if(!dv(o,s))throw Error("Binary was compiled with different texture shapes than the current args. Shape "+o+" and "+s+" must match")}}))}var lU=zL,cU=VL,pU=UL,hU=qL,fU=XL,dU=ZL,mU=$L,vU=tz,gU=nz,yU=az,bU=oz,xU=sz,wU=cz,kU=pz,NU=fz,IU=mz,SU=bz,TU=Sz,CU=Cz,EU=Ez,RU=NL,AU=Az,DU=Oz,FU=Mz,_U=Bz,OU=Wz,MU=kz,LU=Vz;function zU(e,t){return["x","y","z","w","u","v"].slice(0,t).map((function(t){return e+"."+t}))}function PU(e,t){return 1===t?[e]:zU(e,t)}var BU=function(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e;var t=e.length;if(0===t)this.userCode="\n        void main() {\n          setOutput(vec4(getA(), 0., 0., 0.));\n        }\n      ";else{var n=PU("rc",t),r=iU(t),a=function(e,t,n){if(1===e)return"rc > "+t[0];for(var r="",a=e-2;a<e;a++)r+=n[a]+" >= "+t[a],a<e-1&&(r+="||");return r}(t,e,n),i=function(e,t,n,r){if(1===e)return"";var a=r.slice(-2);return"\n    int r = "+a[0]+";\n    int c = "+a[1]+";\n    int rp1 = r + 1;\n    int cp1 = c + 1;\n\n    bool cEdge = cp1 >= "+t+";\n    bool rEdge = rp1 >= "+n+";\n  "}(t,e[e.length-1],e[e.length-2],n),o=function(e,t){var n=e.length,r=function(e,t){for(var n=[],r=0;r<=1;r++)for(var a=0;a<=1;a++){for(var i=(0===r?"r":"rp1")+", "+(0===a?"c":"cp1"),o=2;o<e;o++)i=t[t.length-1-o]+","+i;n.push(i)}return n}(n,t);if(1===n)return"getA(rc),\n            rc + 1 >= "+e[0]+" ? 0. : getA(rc + 1),\n            0, 0";return"getA("+r[0]+"),\n          cEdge ? 0. : getA("+r[1]+"),\n          rEdge ? 0. : getA("+r[2]+"),\n          rEdge || cEdge ? 0. : getA("+r[3]+")"}(e,n);this.userCode="\n        void main() {\n          "+r+" rc = getOutputCoords();\n\n          if("+a+") {\n            setOutput(vec4(0));\n          } else {\n            "+i+"\n\n            setOutput(vec4("+o+"));\n          }\n        }\n      "}};var WU=function(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;for(var n="",r=0;r<4;r++){var a="thisRC = rc;";r%2==1&&(a+="thisRC.z += 1;"),r>1&&(a+="thisRC.y += 1;"),n+="\n        "+a+"\n        "+(r>0?"if(thisRC.y < rows && thisRC.z < cols){":"")+"\n          int flatIndex = getFlatIndex(thisRC);\n\n          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n          vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n          result["+r+"] =\n            getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n        "+(r>0?"}":"")+"\n      "}this.userCode="\n      "+("\n    ivec3 inputCoordsFromReshapedOutCoords(int index) {\n      "+RV(["r","c","d"],t)+"\n      return ivec3(r, c, d);\n    }\n  \n      ")+AV(e)+"\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n\n        vec4 result = vec4(0.);\n\n        ivec3 thisRC;\n        int rows = "+e[1]+";\n        int cols = "+e[2]+";\n\n        "+n+"\n\n        setOutput(result);\n      }\n    "};var VU=function(){function e(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}var t=e.prototype;return t.acquireTexture=function(e,t,n){var r=GU(t,n),a=jU(e,r,n);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);var i,o=UU(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=o,this.log();var s=this.freeTextures[a].shift();return this.usedTextures[a].push(s),s}return r===XW.PACKED_2X2_FLOAT32?i=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===XW.PACKED_2X2_FLOAT16?i=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===XW.UNPACKED_FLOAT32?i=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===XW.UNPACKED_FLOAT16?i=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===XW.PACKED_4X1_UNSIGNED_BYTE&&(i=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(i),this.numUsedTextures++,this._numBytesAllocated+=o,this.log(),i},t.releaseTexture=function(e,t,n,r){if(null!=this.freeTextures){var a=GU(n,r),i=jU(t,a,r);i in this.freeTextures||(this.freeTextures[i]=[]);var o=UU(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,r),s=Xv().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==s&&this._numBytesAllocated>s?(this.gpgpu.deleteMatrixTexture(e),this._numBytesAllocated-=o):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=o),this.numUsedTextures--;var u=this.usedTextures[i],l=u.indexOf(e);if(l<0)throw new Error("Cannot release a texture that was never provided by this texture manager");u.splice(l,1),this.log()}},t.log=function(){if(this.logEnabled){var e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",this.numFreeTextures+" / "+this.numUsedTextures,"("+e+")");var t=this._numBytesFree/this._numBytesAllocated;console.log("Bytes allocated: "+this._numBytesAllocated),console.log("Bytes unused: "+this._numBytesFree+" ("+Math.round(100*t)+"%)")}},t.getNumUsedTextures=function(){return this.numUsedTextures},t.getNumFreeTextures=function(){return this.numFreeTextures},t.dispose=function(){var e=this;if(null!=this.freeTextures){for(var t in this.freeTextures)this.freeTextures[t].forEach((function(t){e.gpgpu.deleteMatrixTexture(t)}));for(var n in this.usedTextures)this.usedTextures[n].forEach((function(t){e.gpgpu.deleteMatrixTexture(t)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}},Hm(e,[{key:"numBytesAllocated",get:function(){return this._numBytesAllocated}},{key:"numBytesFree",get:function(){return this._numBytesFree}}]),e}();function UU(e,t,n,r,a){var i,o=function(e,t){switch(e){case XW.PACKED_2X2_FLOAT32:return HV(t);case XW.PACKED_2X2_FLOAT16:return qV(t);case XW.UNPACKED_FLOAT32:return UV(t);case XW.UNPACKED_FLOAT16:return GV(t);case XW.PACKED_4X1_UNSIGNED_BYTE:return jV(t);default:throw new Error("Unknown physical texture type "+e)}}(t,r);if(a){var s=eV(e[0],e[1]);i=s[0]*s[1]}else{var u=QW(e[0],e[1]);i=u[0]*u[1]}return i*function(e,t){var n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;throw new Error("Unknown internal format "+t)}(n,o)}function GU(e,t){if(e===KW.UPLOAD)return XW.PACKED_2X2_FLOAT32;if(e===KW.RENDER||null==e)return function(e){return Xv().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?XW.PACKED_2X2_FLOAT32:XW.UNPACKED_FLOAT32:e?XW.PACKED_2X2_FLOAT16:XW.UNPACKED_FLOAT16}(t);if(e===KW.DOWNLOAD||e===KW.PIXELS)return XW.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+e)}function jU(e,t,n){return e[0]+"_"+e[1]+"_"+t+"_"+n}var HU=function(e,t){this.variableNames=["A"],this.outputShape=e,this.userCode="\n      float unaryOperation(float x) {\n        "+t+"\n      }\n\n      void main() {\n        float x = getAAtOutCoords();\n        float y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    "},qU="if (isnan(x)) return x;",KU="return abs(x);";var XU="return x;",YU=function(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode="\n      vec4 unaryOperation(vec4 x) {\n        "+t+"\n      }\n\n      void main() {\n        vec4 x = getAAtOutCoords();\n        vec4 y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    "},JU=function(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e;var t=e.length,n=PU("rc",t),r=iU(t),a=function(e,t){if(1===e)return"rc";for(var n="",r=0;r<e;r++)n+=t[r],r<e-1&&(n+=",");return n}(t,n),i=n.slice(-2),o=t<=1?"rc":"vec2("+i.join(",")+")";this.userCode="\n      void main() {\n        "+r+" rc = getOutputCoords();\n        vec4 packedInput = getA("+a+");\n\n        setOutput(getChannel(packedInput, "+o+"));\n      }\n    "},ZU=hI,QU={};var $U=function(e){function t(t){var n,r;if((n=e.call(this)||this).pendingRead=new WeakMap,n.pendingDisposal=new WeakSet,n.dataRefCount=new WeakMap,n.numBytesInGPU=0,n.uploadWaitMs=0,n.downloadWaitMs=0,n.warnedAboutMemory=!1,n.warnedAboutCPUBackend=!1,n.pendingDeletes=0,n.disposed=!1,!Xv().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(null==t){var a=ZW(Xv().getNumber("WEBGL_VERSION"));n.binaryCache=((r=Xv().getNumber("WEBGL_VERSION"))in QU||(QU[r]={}),QU[r]),n.gpgpu=new XV(a),n.canvas=a.canvas,n.gpgpuCreatedLocally=!0}else n.gpgpu=t,n.binaryCache={},n.gpgpuCreatedLocally=!1,n.canvas=t.gl.canvas;return n.textureManager=new VU(n.gpgpu),n.numMBBeforeWarning=null==Xv().global.screen?1024:Xv().global.screen.height*Xv().global.screen.width*window.devicePixelRatio*600/1024/1024,n.texData=new nv(Qm(n),hx()),n}qm(t,e);var n=t.prototype;return n.numDataIds=function(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes},n.write=function(e,t,n){if((Xv().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||Xv().getBool("DEBUG"))&&this.checkNumericalProblems(e),"complex64"===n&&null!=e)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");var r={};return this.texData.set(r,{shape:t,dtype:n,values:e,usage:KW.UPLOAD,refCount:1,complexParentRefCount:0}),r},n.incRef=function(e){this.texData.get(e).refCount++},n.decRef=function(e){this.texData.has(e)&&this.texData.get(e).refCount--},n.move=function(e,t,n,r){if(Xv().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:r,values:t,usage:KW.UPLOAD,refCount:1,complexParentRefCount:0})},n.disposeIntermediateTensorInfo=function(e){var t=e.dataId;if(this.texData.has(t)){var n=this.texData.get(t);n.refCount--,n.refCount<1&&this.disposeData(t)}},n.readSync=function(e){var t=this.texData.get(e),n=t.values,r=t.dtype,a=t.complexTensorInfos,i=t.slice,o=t.shape,s=t.isPacked;if(null!=i){var u;u=s?new YU(o,XU):new HU(o,XU);var l=this.runWebGLProgram(u,[{dataId:e,shape:o,dtype:r}],r),c=this.readSync(l.dataId);return this.disposeIntermediateTensorInfo(l),c}if(null!=n)return this.convertAndCacheOnCPU(e);if("string"===r)return n;var p,h,f=null!=this.activeTimers;(f&&(p=yg()),"complex64"===r)?h=mT(this.readSync(a.real.dataId),this.readSync(a.imag.dataId)):h=this.getValuesFromTexture(e);return f&&(this.downloadWaitMs+=yg()-p),this.convertAndCacheOnCPU(e,h)},n.read=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r,a,i,o,s,u,l,c,p,h,f,d,m,v,g,y,b,x,w,k,N;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.pendingRead.has(t)){e.next=3;break}return n=this.pendingRead.get(t),e.abrupt("return",new Promise((function(e){return n.push(e)})));case 3:if(r=this.texData.get(t),a=r.values,i=r.shape,o=r.slice,s=r.dtype,u=r.complexTensorInfos,l=r.isPacked,null==o){e.next=11;break}return c=l?new YU(i,XU):new HU(i,XU),p=this.runWebGLProgram(c,[{dataId:t,shape:i,dtype:s}],s),h=this.read(p.dataId),this.disposeIntermediateTensorInfo(p),e.abrupt("return",h);case 11:if(null==a){e.next=13;break}return e.abrupt("return",this.convertAndCacheOnCPU(t));case 13:if(Xv().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")||2!==Xv().getNumber("WEBGL_VERSION")){e.next=15;break}throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");case 15:if(f=null,"complex64"!==s&&Xv().get("WEBGL_BUFFER_SUPPORTED")&&(d=this.decode(t),v=this.texData.get(d.dataId),f=(m=this.gpgpu).createBufferFromTexture.apply(m,[v.texture].concat($W(i)))),this.pendingRead.set(t,[]),"complex64"===s){e.next=21;break}return e.next=21,this.gpgpu.createAndWaitForFence();case 21:if("complex64"!==s){e.next=30;break}return e.next=24,Promise.all([this.read(u.real.dataId),this.read(u.imag.dataId)]);case 24:y=e.sent,b=y[0],x=y[1],g=mT(b,x),e.next=31;break;case 30:null==f?g=this.getValuesFromTexture(t):(w=fv(i),g=this.gpgpu.downloadFloat32MatrixFromBuffer(f,w));case 31:return null!=d&&this.disposeIntermediateTensorInfo(d),k=this.convertAndCacheOnCPU(t,g),N=this.pendingRead.get(t),this.pendingRead.delete(t),N.forEach((function(e){return e(k)})),this.pendingDisposal.has(t)&&(this.pendingDisposal.delete(t),this.disposeData(t),this.pendingDeletes--),e.abrupt("return",k);case 38:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.bufferSync=function(e){var t=this.readSync(e.dataId),n=t;if("string"===e.dtype)try{n=t.map((function(e){return wg(e)}))}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return nb(e.shape,e.dtype,n)},n.checkNumericalProblems=function(e){if(null!=e)for(var t=0;t<e.length;t++){var n=e[t];if(!rV(n)){if(Xv().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error("The value "+n+" cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'");throw Error("The value "+n+" cannot be represented on this device.")}}},n.getValuesFromTexture=function(e){var t=this.texData.get(e),n=t.shape,r=t.dtype,a=t.isPacked,i=fv(n);if(Xv().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){var o,s=this.decode(e),u=this.texData.get(s.dataId),l=(o=this.gpgpu).downloadMatrixFromPackedTexture.apply(o,[u.texture].concat($W(n))).subarray(0,i);return this.disposeIntermediateTensorInfo(s),l}var c=Xv().getBool("WEBGL_PACK")&&!0===a,p=c?bV(n):n,h=c?new MV(p):new OV(p),f=this.runWebGLProgram(h,[{shape:p,dtype:r,dataId:e}],"float32"),d=this.texData.get(f.dataId),m=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(d.texture,d.texShape[0],d.texShape[1]).subarray(0,i);return this.disposeIntermediateTensorInfo(f),m},n.time=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n,r,a,i,o,s,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.activeTimers,r=[],a=!1,null==this.programTimersStack?(this.programTimersStack=r,a=!0):this.activeTimers.push(r),this.activeTimers=r,t(),i=hv(this.activeTimers.map((function(e){return e.query}))).filter((function(e){return null!=e})),o=hv(this.activeTimers.map((function(e){return e.name}))).filter((function(e){return null!=e})),this.activeTimers=n,a&&(this.programTimersStack=null),s={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null},!(Xv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)){e.next=19;break}return e.next=14,Promise.all(i);case 14:u=e.sent,s.kernelMs=uv(u),s.getExtraProfileInfo=function(){return u.map((function(e,t){return{name:o[t],ms:e}})).map((function(e){return e.name+": "+e.ms})).join(", ")},e.next=20;break;case 19:s.kernelMs={error:"WebGL query timers are not supported in this environment."};case 20:return this.uploadWaitMs=0,this.downloadWaitMs=0,e.abrupt("return",s);case 23:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.memory=function(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}},n.startTimer=function(){return Xv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:yg(),endMs:null}},n.endTimer=function(e){return Xv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=yg(),e)},n.getQueryTime=function(){var e=Gm(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Xv().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)){e.next=2;break}return e.abrupt("return",this.gpgpu.waitForQueryAndGetTime(t));case 2:return n=t,e.abrupt("return",n.endMs-n.startMs);case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.disposeData=function(e){if(!this.pendingDisposal.has(e)){if(this.pendingRead.has(e))return this.pendingDisposal.add(e),void this.pendingDeletes++;if(this.texData.has(e))if(this.texData.get(e).complexParentRefCount>0)this.texData.get(e).refCount--;else{this.releaseGPUData(e);var t=this.texData.get(e).complexTensorInfos;null!=t&&(this.texData.get(t.real.dataId).complexParentRefCount--,this.disposeIntermediateTensorInfo(t.real),this.texData.get(t.imag.dataId).complexParentRefCount--,this.disposeIntermediateTensorInfo(t.imag)),this.texData.delete(e)}}},n.releaseGPUData=function(e){var t=this.texData.get(e),n=t.texture,r=t.dtype,a=t.texShape,i=t.usage,o=t.isPacked,s=t.slice,u=s&&s.origDataId||e,l=this.dataRefCount.get(u);l>1?this.dataRefCount.set(u,l-1):(this.dataRefCount.delete(u),null!=n&&(this.numBytesInGPU-=this.computeBytes(a,r),this.textureManager.releaseTexture(n,a,i,o)));var c=this.texData.get(e);c.texture=null,c.texShape=null,c.isPacked=!1,c.slice=null},n.getTexture=function(e){return this.uploadToGPU(e),this.texData.get(e).texture},n.getDataInfo=function(e){return this.texData.get(e)},n.getCPUBackend=function(){return Xv().getBool("WEBGL_CPU_FORWARD")?(null==this.cpuBackend&&(this.cpuBackend=hx().findBackend("cpu")),this.cpuBackend):null},n.shouldExecuteOnCPU=function(e,t){var n=this;void 0===t&&(t=128);var r=this.getCPUBackend();return Xv().getBool("IS_TEST")||this.warnedAboutCPUBackend||null!=r||(console.warn("Your application contains ops that are small enough to be executed on the CPU backend, however the CPU backend cannot be found. Consider importing the CPU backend (@tensorflow/tfjs-backend-cpu) for better performance."),this.warnedAboutCPUBackend=!0),null!=r&&e.every((function(e){return null==n.texData.get(e.dataId).texture&&fv(e.shape)<t}))},n.getGPGPUContext=function(){return this.gpgpu},n.where=function(e){dT("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");var t=e.dataSync();return ZU(e.shape,t)},n.packedUnaryOp=function(e,t,n){var r=new YU(e.shape,t);return this.compileAndRun(r,[e],n)},n.abs=function(e){if(this.shouldExecuteOnCPU([e])&&"complex64"!==e.dtype){var t=RU(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,t)}if(Xv().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,KU,e.dtype);var n=new HU(e.shape,KU);return this.compileAndRun(n,[e])},n.makeTensorInfo=function(e,t,n){var r;if("string"===t&&null!=n&&n.length>0&&Av(n[0])){var a=n.map((function(e){return xg(e)}));r=this.write(a,e,t)}else r=this.write(n,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}},n.makeOutput=function(e,t,n){var r=this.makeTensorInfo(e,t,n).dataId;return hx().makeTensorFromDataId(r,e,t,this)},n.unpackTensor=function(e){var t=new JU(e.shape);return this.runWebGLProgram(t,[e],e.dtype)},n.packTensor=function(e){var t=new BU(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)},n.packedReshape=function(e,t){var n=[gV(e.shape)].concat(yV(e.shape)),r={dtype:e.dtype,shape:n,dataId:e.dataId},a=[gV(t)].concat(yV(t)),i=new WU(a,n),o=this.runWebGLProgram(i,[r],e.dtype,null,!0);return{dataId:o.dataId,shape:t,dtype:o.dtype}},n.decode=function(e){var t,n=this.texData.get(e),r=n.isPacked,a=n.shape,i=n.dtype,o=bV(a);t=r?new _V(o):new FV(o);return{dtype:i,shape:a,dataId:this.runWebGLProgram(t,[{shape:o,dtype:i,dataId:e}],i,null,!0).dataId}},n.runWebGLProgram=function(e,t,n,r,a){var i=this;void 0===a&&(a=!1);var o=this.makeTensorInfo(e.outputShape,n),s=this.texData.get(o.dataId);if(e.packedOutput&&(s.isPacked=!0),e.outPackingScheme===qW.DENSE){var u=$W(e.outputShape);s.texShape=u.map((function(e){return 2*e}))}if(null!=e.outTexUsage&&(s.usage=e.outTexUsage),0===fv(o.shape))return s.values=kv(o.dtype,0),o;var l=[],c=t.map((function(t){if("complex64"===t.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");var n=i.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&fv(t.shape)<=Xv().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:t.shape,texData:null,isUniform:!0,uniformValues:n.values};e.packedInputs&&(n.isPacked=!0,n.shape=t.shape)}else if(!!n.isPacked!=!!e.packedInputs)t=n.isPacked?i.unpackTensor(t):i.packTensor(t),l.push(t),n=i.texData.get(t.dataId);else if(n.isPacked&&!wV(n.shape,t.shape)){var r=t,a=t.shape;t.shape=n.shape,t=i.packedReshape(t,a),l.push(t),n=i.texData.get(t.dataId),r.shape=a}return i.uploadToGPU(t.dataId),{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(o.dataId);var p,h={shape:o.shape,texData:s,isUniform:!1},f=function(e,t,n){var r="";t.concat(n).forEach((function(e){var t=null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0,n=e.isUniform?"uniform":e.texData.texShape;r+=e.shape+"_"+n+"_"+t}));var a=e.userCode,i=e.constructor.name;return i+="_"+r+"_"+a}(e,c,h),d=this.getAndSaveBinary(f,(function(){return function(e,t,n,r){var a=t.userCode,i=n.map((function(e,n){var r={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(r.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[n],shapeInfo:r}})),o=i.map((function(e){return e.shapeInfo})),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},u=JV(i,s,a,t.packedInputs),l=e.createProgram(u),c=null,p=e.getUniformLocation(l,"NAN",!1);1===Xv().getNumber("WEBGL_VERSION")&&(c=e.getUniformLocation(l,"INFINITY",!1));for(var h={},f=0;f<t.variableNames.length;f++){var d=t.variableNames[f];h[d]=e.getUniformLocation(l,d,!1),h["offset"+d]=e.getUniformLocation(l,"offset"+d,!1)}return{program:t,source:u,webGLProgram:l,uniformLocations:h,inShapeInfos:o,outShapeInfo:s,infLoc:c,nanLoc:p}}(i.gpgpu,e,c,h)})),m=null!=this.activeTimers;if(m&&(p=this.startTimer()),function(e,t,n,r,a){uU(t.inShapeInfos,n),uU([t.outShapeInfo],[r]);var i=r.texData.texture,o=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(i,o[0],o[1]):e.setOutputMatrixTexture(i,o[0],o[1]),e.setProgram(t.webGLProgram),1===Xv().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach((function(n,r){var a=t.program.variableNames[r],i=t.uniformLocations[a],o=t.uniformLocations["offset"+a];if(null!=i)if(n.isUniform)if(fv(n.shape)<2)e.gl.uniform1f(i,n.uniformValues[0]);else{var s=n.uniformValues;s instanceof Float32Array||(s=new Float32Array(s)),e.gl.uniform1fv(i,s)}else null!=n.texData.slice&&null!=o&&e.gl.uniform1i(o,n.texData.slice.flatOffset),e.setInputMatrixTexture(n.texData.texture,i,r)})),null!=a&&a(e,t.webGLProgram),e.executeProgram()}(this.gpgpu,d,c,h,r),l.forEach((function(e){return i.disposeIntermediateTensorInfo(e)})),m&&(p=this.endTimer(p),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(p)})),!Xv().getBool("WEBGL_LAZILY_UNPACK")&&s.isPacked&&!1===a){var v=this.unpackTensor(o);return this.disposeIntermediateTensorInfo(o),v}return o},n.compileAndRun=function(e,t,n,r,a){void 0===a&&(a=!1),n=n||t[0].dtype;var i=this.runWebGLProgram(e,t,n,r,a);return hx().makeTensorFromDataId(i.dataId,i.shape,i.dtype)},n.getAndSaveBinary=function(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]},n.getTextureManager=function(){return this.textureManager},n.dispose=function(){var e=this;if(!this.disposed){if(!Xv().getBool("IS_TEST"))Object.keys(this.binaryCache).forEach((function(t){e.gpgpu.deleteProgram(e.binaryCache[t].webGLProgram),delete e.binaryCache[t]}));this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0}},n.floatPrecision=function(){var e=this;return null==this.floatPrecisionValue&&(this.floatPrecisionValue=dx((function(){if(!Xv().get("WEBGL_RENDER_FLOAT32_ENABLED")){var t=Xv().getBool("DEBUG");Xv().set("DEBUG",!1);var n=e.abs(_N(1e-8)).dataSync()[0];if(Xv().set("DEBUG",t),n>0)return 32}return 16}))),this.floatPrecisionValue},n.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4},n.uploadToGPU=function(e){var t=this.texData.get(e),n=t.shape,r=t.dtype,a=t.values,i=t.texture,o=t.usage,s=t.isPacked;if(null==i){var u,l=null!=this.activeTimers;l&&(u=yg());var c=t.texShape;if(null==c&&(c=function(e,t){void 0===t&&(t=!1);var n=Xv().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t&&(n*=2,1===(e=e.map((function(t,n){return n>=e.length-2?sv(e[n]):e[n]}))).length&&(e=[2,e[0]])),2!==e.length){var r=wv(e);e=r.newShape}var a=fv(e);if(e.length<=1&&a<=n)return[1,a];if(2===e.length&&e[0]<=n&&e[1]<=n)return e;if(3===e.length&&e[0]*e[1]<=n&&e[2]<=n)return[e[0]*e[1],e[2]];if(3===e.length&&e[0]<=n&&e[1]*e[2]<=n)return[e[0],e[1]*e[2]];if(4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n)return[e[0]*e[1]*e[2],e[3]];if(4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n)return[e[0],e[1]*e[2]*e[3]];if(t){var i=gV(e),o=2,s=2;if(e.length){var u=yV(e);o=u[0],s=u[1]}return vv(a=i*(o/2)*(s/2)).map((function(e){return 2*e}))}return vv(a)}(n,s),t.texShape=c),null!=a){var p,h=bV(n),f=c[1],d=c[0],m=a instanceof Uint8Array;if(s){var v=eV(c[0],c[1]);f=v[0],d=v[1],p=new zV(h,[d,f],m)}else p=new LV(h,[d,f],m);var g=this.makeTensorInfo([d,f],r);this.texData.get(g.dataId).usage=m?KW.PIXELS:KW.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(g.dataId),f,d,a);var y=this.runWebGLProgram(p,[g],r,null,!0),b=this.texData.get(y.dataId);t.texture=b.texture,t.texShape=b.texShape,t.isPacked=b.isPacked,t.usage=b.usage,this.disposeIntermediateTensorInfo(g),this.texData.delete(y.dataId),t.values=null,l&&(this.uploadWaitMs+=yg()-u)}else{var x=this.acquireTexture(c,o,r,s);t.texture=x}}},n.convertAndCacheOnCPU=function(e,t){var n=this.texData.get(e),r=n.dtype;return this.releaseGPUData(e),null!=t&&(n.values=function(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){for(var n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length),r=0;r<n.length;++r)n[r]=Math.round(e[r]);return n}throw new Error("Unknown dtype "+t)}(t,r)),n.values},n.acquireTexture=function(e,t,n,r){if(this.numBytesInGPU+=this.computeBytes(e,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){var a=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn("High memory usage in GPU: "+a+" MB, most likely due to a memory leak")}return this.textureManager.acquireTexture(e,t,r)},n.computeBytes=function(e,t){return e[0]*e[1]*Ev(t)},t}(rv);$g()&&yx("webgl",(function(){return new $U}),2);var eG=function(e,t,n){this.variableNames=["A","B"],this.outputShape=Ow(t,n),this.userCode="\n      float binaryOperation(float a, float b) {\n        "+e+"\n      }\n\n      void main() {\n        float a = getAAtOutCoords();\n        float b = getBAtOutCoords();\n        setOutput(binaryOperation(a, b));\n      }\n    "},tG=function(e,t,n,r){void 0===r&&(r=!1),this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=Ow(t,n);var a=this.outputShape.length,i="";if(r)if(0===a||1===fv(this.outputShape))i="\n          result.y = 0.;\n          result.z = 0.;\n          result.w = 0.;\n        ";else if(i="\n          "+iU(a)+" coords = getOutputCoords();\n        ",1===a)i+="\n            result.y = (coords + 1) >= "+this.outputShape[0]+" ? 0. : result.y;\n            result.z = 0.;\n            result.w = 0.;\n          ";else{var o=PU("coords",a);i+="\n            bool nextRowOutOfBounds =\n              ("+o[a-2]+" + 1) >= "+this.outputShape[a-2]+";\n            bool nextColOutOfBounds =\n              ("+o[a-1]+" + 1) >= "+this.outputShape[a-1]+";\n            result.y = nextColOutOfBounds ? 0. : result.y;\n            result.z = nextRowOutOfBounds ? 0. : result.z;\n            result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n          "}this.userCode="\n      vec4 binaryOperation(vec4 a, vec4 b) {\n        "+e+"\n      }\n\n      void main() {\n        vec4 a = getAAtOutCoords();\n        vec4 b = getBAtOutCoords();\n\n        vec4 result = binaryOperation(a, b);\n        "+i+"\n\n        setOutput(result);\n      }\n    "};function nG(e){var t=e.inputs,n=e.backend,r=t.x;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}var rG={kernelName:"Identity",backendName:"webgl",kernelFunc:nG};function aG(e){var t=e.inputs,n=e.backend,r=t.real,a=t.imag,i=n.makeTensorInfo(r.shape,"complex64"),o=n.texData.get(i.dataId),s=nG({inputs:{x:r},backend:n});n.texData.get(s.dataId).complexParentRefCount++;var u=nG({inputs:{x:a},backend:n});return n.texData.get(u.dataId).complexParentRefCount++,o.complexTensorInfos={real:s,imag:u},i}var iG={kernelName:"Complex",backendName:"webgl",kernelFunc:aG},oG="return (a < 0.) ? b * a : a;",sG="\n  vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n  return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";var uG={kernelName:"LeakyRelu",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.alpha,o=n.makeTensorInfo([],"float32",vg(i,"float32")),s=Xv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new tG(sG,a.shape,o.shape):new eG(oG,a.shape,o.shape),u=n.runWebGLProgram(s,[a,o],a.dtype);return n.disposeIntermediateTensorInfo(o),u}},lG="return (a < 0.) ? b * a : a;",cG="\n  vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n  return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n";var pG={kernelName:"Prelu",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,a=t.alpha,i=Xv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new tG(cG,r.shape,a.shape):new eG(lG,r.shape,a.shape);return n.runWebGLProgram(i,[r,a],r.dtype)}};function hG(e){var t=e.opSnippet,n=e.packedOpSnippet,r=e.cpuKernelImpl,a=e.dtype;return function(e){var i,o=e.inputs,s=e.backend,u=o.x,l=s,c=a||u.dtype;if(l.shouldExecuteOnCPU([u])&&null!=r){var p=l.texData.get(u.dataId),h=r(p.values,c);return l.makeTensorInfo(u.shape,c,h)}return i=Xv().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=n?new YU(u.shape,n):new HU(u.shape,t),l.runWebGLProgram(i,[u],c)}}function fG(e){var t=e.opSnippet,n=e.packedOpSnippet,r=e.checkOutOfBounds,a=void 0!==r&&r,i=e.supportsComplex,o=void 0!==i&&i,s=e.cpuKernelImpl,u=e.dtype;return function(e){var r=e.inputs,i=e.backend,l=r.a,c=r.b,p=i;if(o&&"complex64"===l.dtype){var h=p.texData.get(l.dataId),f=p.texData.get(c.dataId),d=[[h.complexTensorInfos.real,f.complexTensorInfos.real],[h.complexTensorInfos.imag,f.complexTensorInfos.imag]].map((function(e){var n=e[0],r=e[1],a={dataId:n.dataId,dtype:n.dtype,shape:l.shape},i={dataId:r.dataId,dtype:r.dtype,shape:c.shape},o=new eG(t,l.shape,c.shape);return p.runWebGLProgram(o,[a,i],Wg(n.dtype,r.dtype))})),m=d[0],v=d[1],g=aG({inputs:{real:m,imag:v},backend:p});return p.disposeIntermediateTensorInfo(m),p.disposeIntermediateTensorInfo(v),g}var y,b=u||Wg(l.dtype,c.dtype);if(p.shouldExecuteOnCPU([l,c])&&null!=s){var x=p.texData.get(l.dataId),w=p.texData.get(c.dataId),k=s(l.shape,c.shape,x.values,w.values,b),N=k[0],I=k[1],S=p.makeTensorInfo(I,b);return p.texData.get(S.dataId).values=N,S}return y=Xv().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=n?new tG(n,l.shape,c.shape,a):new eG(t,l.shape,c.shape),p.runWebGLProgram(y,[l,c],b)}}function dG(e,t){if(void 0===t&&(t=!1),"linear"===e)return"return x;";if("relu"===e)return t?"\n  vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n  bvec4 isNaN = isnan(x);\n\n  result.r = isNaN.r ? x.r : result.r;\n  result.g = isNaN.g ? x.g : result.g;\n  result.b = isNaN.b ? x.b : result.b;\n  result.a = isNaN.a ? x.a : result.a;\n\n  return result;\n":"if (isnan(x)) return x;\n  return (x < 0.0) ? 0.0 : x;\n";if("elu"===e)return t?"\n  vec4 result;\n\n  result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n  result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n  result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n  result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n  return result;\n":"return (x >= 0.0) ? x : (exp(x) - 1.0);";if("relu6"===e)return t?"\n  vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n  bvec4 isNaN = isnan(x);\n\n  result.r = isNaN.r ? x.r : result.r;\n  result.g = isNaN.g ? x.g : result.g;\n  result.b = isNaN.b ? x.b : result.b;\n  result.a = isNaN.a ? x.a : result.a;\n\n  return result;\n":"if (isnan(x)) return x;\n  return (x < 0.0) ? 0.0 : min(6.0, x);\n";if("prelu"===e)return t?cG:lG;if("leakyrelu"===e)return t?sG:oG;throw new Error("Activation "+e+" has not been implemented for the WebGL backend.")}var mG=function(e,t,n,r,a,i,o,s,u){void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===i&&(i=!1),void 0===o&&(o=null),void 0===s&&(s=!1),void 0===u&&(u=!1),this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n;var l=r?e[1]:e[2],c=Math.ceil(l/2),p=r?"i * 2, rc.y":"rc.y, i * 2",h=a?"rc.z, i * 2":"i * 2, rc.z",f=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],d=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],m="",v="";o&&(m=s?"vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          "+o+"\n        }":u?"vec4 activation(vec4 a) {\n          vec4 b = getLeakyreluAlphaAtOutCoords();\n          "+o+"\n        }":"vec4 activation(vec4 x) {\n          "+o+"\n        }",v="result = activation(result);");var g=i?"result += getBiasAtOutCoords();":"";i&&this.variableNames.push("bias"),s&&this.variableNames.push("preluActivationWeights"),u&&this.variableNames.push("leakyreluAlpha");var y="rc.x",b="rc.x";e[0]<t[0]?y="int(min(float(rc.x), "+(e[0]-1)+".))":t[0]<e[0]&&(b="int(min(float(rc.x), "+(t[0]-1)+".))"),this.userCode="\n      "+m+"\n\n      const float sharedDimension = "+c+".0;\n\n      vec4 dot2x2ARowBCol(ivec3 rc) {\n        vec4 result = vec4(0);\n        for (int i = 0; i < "+c+"; i++) {\n          int batchA = "+y+";\n          int batchB = "+b+";\n          vec4 a = getMatrixA(batchA, "+p+");\n          vec4 b = getMatrixB(batchB, "+h+");\n\n          // These swizzled products need to be separately added.\n          // See: https://github.com/tensorflow/tfjs/issues/1735\n          result += ("+f[0]+" * "+d[0]+");\n          result += ("+f[1]+" * "+d[1]+");\n        }\n        return result;\n      }\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n        vec4 result = dot2x2ARowBCol(rc);\n\n        "+g+"\n\n        "+v+"\n\n        setOutput(result);\n      }\n    "},vG="return areal * breal - aimag * bimag;",gG="return areal * bimag + aimag * breal;",yG=function(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=Ow(t,n),this.userCode="\n      float binaryOpComplex(\n          float areal, float aimag, float breal, float bimag) {\n        "+e+"\n      }\n\n      void main() {\n        float areal = getARealAtOutCoords();\n        float aimag = getAImagAtOutCoords();\n        float breal = getBRealAtOutCoords();\n        float bimag = getBImagAtOutCoords();\n        setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n      }\n    "},bG="return a * b;";function xG(e){var t,n=e.inputs,r=e.backend,a=n.a,i=n.b,o=Wg(a.dtype,i.dtype);if("complex64"===a.dtype){var s=r.texData.get(a.dataId),u=r.texData.get(i.dataId),l=new yG(vG,a.shape,i.shape),c=new yG(gG,a.shape,i.shape),p=[{dataId:s.complexTensorInfos.real.dataId,dtype:s.complexTensorInfos.real.dtype,shape:a.shape},{dataId:s.complexTensorInfos.imag.dataId,dtype:s.complexTensorInfos.imag.dtype,shape:a.shape},{dataId:u.complexTensorInfos.real.dataId,dtype:u.complexTensorInfos.real.dtype,shape:i.shape},{dataId:u.complexTensorInfos.imag.dataId,dtype:u.complexTensorInfos.imag.dtype,shape:i.shape}],h=r.runWebGLProgram(l,p,"float32"),f=r.runWebGLProgram(c,p,"float32"),d=aG({inputs:{real:h,imag:f},backend:r});return r.disposeIntermediateTensorInfo(h),r.disposeIntermediateTensorInfo(f),d}if(r.shouldExecuteOnCPU([a,i])){var m=r.texData.get(a.dataId),v=r.texData.get(i.dataId),g=IU(a.shape,i.shape,m.values,v.values,o),y=g[0],b=g[1],x=r.makeTensorInfo(b,o);return r.texData.get(x.dataId).values=y,x}return t=Xv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new tG(bG,a.shape,i.shape):new eG(bG,a.shape,i.shape),r.runWebGLProgram(t,[a,i],o)}var wG={kernelName:"Multiply",backendName:"webgl",kernelFunc:xG};function kG(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.shape,o=n,s=fv(a.shape),u=bv(i,s),l=fv(u);lv(s===l,(function(){return"The new shape ("+u+") has "+l+" elements and the old shape ("+a.shape+") has "+s+" elements. The new shape and old shape must have the same number of elements."}));var c=o.texData.get(a.dataId);return!c.isPacked||wV(a.shape,u)||null!==c.texture&&wV(c.shape,u)?(o.incRef(a.dataId),{dataId:a.dataId,shape:u,dtype:a.dtype}):function(e,t,n){var r=[gV(e.shape)].concat(yV(e.shape)),a={dtype:e.dtype,shape:r,dataId:e.dataId},i=[gV(t)].concat(yV(t)),o=new WU(i,r),s=n.runWebGLProgram(o,[a],e.dtype,null,!0);return{dataId:s.dataId,shape:t,dtype:s.dtype}}(a,u,o)}var NG={kernelName:"Reshape",backendName:"webgl",kernelFunc:kG},IG=function(e,t){this.variableNames=["x"];var n=e.windowSize,r=e.batchSize,a=e.inSize,i=e.outSize;this.outputShape=[r,i];var o=4*Math.floor(n/4),s=n%4,u="sumValue += dot(values, ones);";if(null!=t){var l=1/t;u="sumValue += dot(values * "+(mv(l)?l.toPrecision(2):l)+", ones);"}var c="";a%n>0&&(c="\n        if (inIdx < 0 || inIdx >= "+a+") {\n          return 0.0;\n        }\n      "),this.userCode="\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float getValue(int batch, int inIdx) {\n        "+c+"\n        return getX(batch, inIdx);\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = outIdx * "+n+";\n\n        float sumValue = 0.0;\n\n        for (int i = 0; i < "+o+"; i += 4) {\n          int inIdx = inOffset + i;\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            getValue(batch, inIdx + 3)\n          );\n\n          "+u+"\n        }\n\n        int inIdx = inOffset + "+o+";\n        if ("+(1===s)+") {\n          vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n          "+u+"\n        } else if ("+(2===s)+") {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1), 0.0, 0.0);\n\n          "+u+"\n        } else if ("+(3===s)+") {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2), 0.0);\n\n          "+u+"\n        }\n        setOutput(sumValue);\n      }\n    "},SG=function(e,t){this.variableNames=["x"];var n=e.windowSize,r=e.batchSize,a=e.inSize,i=e.outSize;this.outputShape=[r,i];var o="0.0",s="";"prod"===t?o="1.0":"min"===t?(o="1.0 / 1e-20",s="min"):"max"===t&&(o="-1.0 / 1e-20",s="max");var u=t+"("+t+"("+t+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"sum"===t?u="sumValue":"prod"===t?u="prodValue":"all"===t?u="allValue":"any"===t&&(u="anyValue");var l=4*Math.floor(n/4),c=n%4,p="\n      if ("+("sum"===t)+") {\n        sumValue += dot(values, ones);\n      } else if ("+("prod"===t)+") {\n        vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n        prodValue *= tmp[0] * tmp[1];\n      } else {\n        minMaxValue = "+s+"(values, minMaxValue);\n      }\n    ",h="vec4";"all"===t?(o="1.0",p="\n        bool reducedAllValue = all(values);\n        float floatedReducedAllValue = float(reducedAllValue);\n        allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n      ",h="bvec4"):"any"===t&&(o="0.0",p="\n        bool reducedAnyValue = any(values);\n        float floatedReducedAnyValue = float(reducedAnyValue);\n        anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n      ",h="bvec4");var f="";a%n>0&&(f="\n        if (inIdx < 0 || inIdx >= "+a+") {\n          return initializationValue;\n        }\n      "),this.userCode="\n      const float initializationValue = "+o+";\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float getValue(int batch, int inIdx) {\n        "+f+"\n        return getX(batch, inIdx);\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = outIdx * "+n+";\n\n        vec4 minMaxValue = vec4("+o+");\n        float prodValue = 1.0;\n        float sumValue = 0.0;\n        float allValue = 1.0;\n        float anyValue = 0.0;\n\n        for (int i = 0; i < "+l+"; i += 4) {\n          int inIdx = inOffset + i;\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            getValue(batch, inIdx + 3)\n          );\n\n          "+p+"\n        }\n\n        int inIdx = inOffset + "+l+";\n        if ("+(1===c)+") {\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            initializationValue,\n            initializationValue,\n            initializationValue\n          );\n\n          "+p+"\n        } else if ("+(2===c)+") {\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            initializationValue,\n            initializationValue\n          );\n\n          "+p+"\n        } else if ("+(3===c)+") {\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            initializationValue\n          );\n\n          "+p+"\n        }\n        setOutput("+u+");\n      }\n    "};function TG(e,t,n,r){for(var a=function(e){for(var t=[];0===t.length||1!==t[t.length-1].outSize;){var n=t.length?t[t.length-1].outSize:e[1],r=oT(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}(e.shape),i=e,o=0;o<a.length;o++){var s,u=a[o],l=u.inSize,c=u.windowSize,p=u.outSize,h=void 0;h="mean"===n?0===o?new IG({windowSize:c,inSize:l,batchSize:e.shape[0],outSize:p},l):new IG({windowSize:c,inSize:l,batchSize:e.shape[0],outSize:p}):new SG({windowSize:c,inSize:l,batchSize:e.shape[0],outSize:p},n),s=i,i=r.runWebGLProgram(h,[i],t),s.dataId!==e.dataId&&r.disposeIntermediateTensorInfo(s)}return i}var CG=function(e,t){this.variableNames=["A"];for(var n=new Array(e.length),r=0;r<n.length;r++)n[r]=e[t[r]];this.outputShape=n,this.rank=n.length;var a=iU(this.rank),i=function(e){var t=e.length;if(t>6)throw Error("Transpose for rank "+t+" is not yet supported");for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t),a=0;a<e.length;a++)r[e[a]]=n[a];return r.join()}(t);this.userCode="\n    void main() {\n      "+a+" resRC = getOutputCoords();\n      setOutput(getA("+i+"));\n    }\n    "};var EG=function(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;for(var n=new Array(e.length),r=0;r<n.length;r++)n[r]=e[t[r]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error("Packed transpose for rank "+this.rank+" is not yet supported.");for(var a=iU(this.rank),i=zU("rc",this.rank),o=new Array(this.rank),s=0;s<t.length;s++)o[t[s]]=i[s];var u="vec2("+o.slice(-2).join()+")",l="++"+i[this.rank-1]+" < "+n[this.rank-1],c="getChannel(getA("+o.join()+"), "+u+")";this.userCode="\n    void main() {\n      "+a+" rc = getOutputCoords();\n      vec4 result = vec4(0.);\n      result[0] = "+c+";\n      if("+l+") {\n        result[1] = "+c+";\n      }\n      --"+i[this.rank-1]+";\n      if(++"+i[this.rank-2]+" < "+n[this.rank-2]+") {\n        result[2] = "+c+";\n        if("+l+") {\n          result[3] = "+c+";\n        }\n      }\n      setOutput(result);\n    }\n    "};function RG(e,t,n){var r=Xv().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new EG(e.shape,t):new CG(e.shape,t);return n.runWebGLProgram(r,[e],e.dtype)}function AG(e){var t=e.inputs,n=e.backend,r=e.attrs;return function(e,t,n,r){var a=t,i=e.shape.length,o=xv(a,e.shape),s=o,u=Ik(s,i),l=null!=u,c=e;l&&(c=RG(e,u,r),s=Tk(s.length,i)),Nk("sum",s,i);var p=wk(c.shape,s),h=p[0],f=p[1],d=h;n&&(d=kk(h,o));var m=fv(f),v=kG({inputs:{x:c},attrs:{shape:[fv(e.shape)/m,m]},backend:r}),g=TG(v,Vg(e.dtype),"sum",r),y=kG({inputs:{x:g},attrs:{shape:d},backend:r});return r.disposeIntermediateTensorInfo(v),r.disposeIntermediateTensorInfo(g),l&&r.disposeIntermediateTensorInfo(c),y}(t.x,r.axis,r.keepDims,n)}var DG={kernelName:"Sum",backendName:"webgl",kernelFunc:AG};function FG(e){for(var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=a.perm,s=r,u=i.shape.length,l=new Array(u),c=0;c<l.length;c++)l[c]=i.shape[o[c]];if(s.shouldExecuteOnCPU([i])){var p=s.texData.get(i.dataId).values,h=MU(p,i.shape,i.dtype,o,l);t=s.makeTensorInfo(l,i.dtype),s.texData.get(t.dataId).values=h}else t=RG(i,o,s);return t}var _G={kernelName:"Transpose",backendName:"webgl",kernelFunc:FG};function OG(e){var t=e.a,n=e.b,r=e.transposeA,a=e.transposeB,i=e.backend,o=e.bias,s=void 0===o?null:o,u=e.preluActivationWeights,l=void 0===u?null:u,c=e.leakyreluAlpha,p=void 0===c?0:c,h=e.activation,f=void 0===h?null:h,d=t.shape.length,m=n.shape.length,v=r?t.shape[d-2]:t.shape[d-1],g=a?n.shape[m-1]:n.shape[m-2],y=r?t.shape[d-1]:t.shape[d-2],b=a?n.shape[m-2]:n.shape[m-1],x=t.shape.slice(0,-2),w=n.shape.slice(0,-2),k=fv(x),N=fv(w);lv(d>=2&&m>=2&&(k===N||1===k||1===N),(function(){return"Error in matMul: the input batch dimensions must either be the same or at least one input batch dimension must be 1. Got input batch dimensions of ("+x+") and ("+w+")."}));var I=(k>N?t.shape.slice(0,-2):n.shape.slice(0,-2)).concat([y,b]);lv(v===g,(function(){return"Error in matMul: inner shapes ("+v+") and ("+g+") of Tensors with shapes "+t.shape+" and "+n.shape+" and transposeA="+r+" and transposeB="+a+" must match."}));var S,T=r?[k,v,y]:[k,y,v],C=a?[N,b,g]:[N,g,b],E=kG({inputs:{x:t},backend:i,attrs:{shape:T}}),R=kG({inputs:{x:n},backend:i,attrs:{shape:C}}),A=[E,R],D=Math.max(k,N),F=r?E.shape[1]:E.shape[2],_=null!=s,O=null!=l,M="leakyrelu"===f,L=null!=f?dG(f,!0):null;if((1===y||1===b)&&F>1e3&&!1===(_||O||M||null!=L)){var z=E,P=R;r&&(z=FG({inputs:{x:E},backend:i,attrs:{perm:[0,2,1]}}),A.push(z)),a&&(P=FG({inputs:{x:R},backend:i,attrs:{perm:[0,2,1]}}),A.push(P));var B=1===b,W=z;1!==b&&(W=kG({inputs:{x:z},backend:i,attrs:{shape:[D,F,1]}}),A.push(W));var V=1===b?2:1,U=P;B&&(U=kG({inputs:{x:P},backend:i,attrs:{shape:[D,1,F]}}),A.push(U));var G=xG({inputs:{a:W,b:U},backend:i});S=AG({inputs:{x:G},backend:i,attrs:{axis:V,keepDims:!0}}),A.push(G)}else{var j=Wg(t.dtype,n.dtype),H=new mG(T,C,[D,y,b],r,a,_,L,O,M),q=[E,R];if(null!=s&&q.push(s),O&&q.push(l),M){var K=i.makeTensorInfo([],"float32",vg(p,"float32"));q.push(K),A.push(K)}S=i.runWebGLProgram(H,q,j)}var X=kG({inputs:{x:S},backend:i,attrs:{shape:I}});A.push(S);for(var Y=0,J=A;Y<J.length;Y++){var Z=J[Y];i.disposeIntermediateTensorInfo(Z)}return X}var MG={kernelName:"_FusedMatMul",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.a,i=t.b,o=t.bias,s=t.preluActivationWeights,u=r.transposeA,l=r.transposeB,c=r.activation;return OG({a:a,b:i,transposeA:u,transposeB:l,backend:n,bias:o,preluActivationWeights:s,leakyreluAlpha:r.leakyreluAlpha,activation:c})}};var LG={kernelName:"Abs",backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=n.x;if(r.shouldExecuteOnCPU([a])&&"complex64"!==a.dtype){var i=r.texData.get(a.dataId),o=RU(i.values);return r.makeTensorInfo(a.shape,a.dtype,o)}return t=Xv().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new YU(a.shape,"return abs(x);"):new HU(a.shape,"return abs(x);"),r.runWebGLProgram(t,[a],a.dtype)}},zG={kernelName:"Acos",backendName:"webgl",kernelFunc:hG({opSnippet:"if (isnan(x)) return x;\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return acos(x);\n"})},PG={kernelName:"Acosh",backendName:"webgl",kernelFunc:hG({opSnippet:"if (isnan(x)) return x;\n  if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));"})},BG="return a + b;",WG=fG({opSnippet:BG,packedOpSnippet:BG,supportsComplex:!0,cpuKernelImpl:lU}),VG={kernelName:Zv,backendName:"webgl",kernelFunc:WG},UG=function(e,t){this.outputShape=[],this.outputShape=e,this.variableNames=t.map((function(e,t){return"T"+t}));var n=[];this.variableNames.forEach((function(e){n.push("float v"+e+" = get"+e+"AtOutCoords();")}));var r=this.variableNames.map((function(e){return"v"+e})).join(" + ");this.userCode="\n      void main() {\n        "+n.join("\n        ")+"\n\n        float result = "+r+";\n        setOutput(result);\n      }\n    "},GG=function(e,t){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.variableNames=t.map((function(e,t){return"T"+t}));var n=[];this.variableNames.forEach((function(e){n.push("vec4 v"+e+" = get"+e+"AtOutCoords();")}));var r=this.variableNames.map((function(e){return"v"+e})).join(" + ");this.userCode="\n      void main() {\n        "+n.join("\n        ")+"\n\n        vec4 result = "+r+";\n        setOutput(result);\n      }\n    "};var jG={kernelName:"AddN",backendName:"webgl",kernelFunc:function e(t){var n=t.inputs,r=t.backend,a=n;if(1===a.length)return nG({inputs:{x:a[0]},backend:r});if(a.length>Xv().get("WEBGL_MAX_TEXTURES_IN_SHADER")){var i=Math.floor(a.length/2),o=e({inputs:a.slice(0,i),backend:r}),s=e({inputs:a.slice(i),backend:r});return e({inputs:[o,s],backend:r})}var u=a.map((function(e){return e.dtype})).reduce((function(e,t){return Wg(e,t)})),l=a.map((function(e){return e.shape})),c=Xv().getBool("WEBGL_PACK")?new GG(a[0].shape,l):new UG(a[0].shape,l);return r.runWebGLProgram(c,a,u)}};var HG={kernelName:"All",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims,s=a.shape.length,u=xv(i,a.shape),l=u,c=Ik(l,s),p=a;null!=c&&(p=FG({inputs:{x:a},backend:n,attrs:{perm:c}}),l=Tk(l.length,s)),Nk("all",l,s);var h,f=wk(p.shape,l),d=f[0],m=kG({inputs:{x:p},backend:n,attrs:{shape:[-1,fv(f[1])]}}),v=TG(m,m.dtype,"all",n);return h=kG(o?{inputs:{x:v},backend:n,attrs:{shape:kk(d,u)}}:{inputs:{x:v},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v),null!=c&&n.disposeIntermediateTensorInfo(p),h}};var qG={kernelName:"Any",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims,s=a.shape.length,u=xv(i,a.shape),l=u,c=Ik(l,s),p=a;null!=c&&(p=FG({inputs:{x:a},backend:n,attrs:{perm:c}}),l=Tk(l.length,s)),Nk("any",l,s);var h,f=wk(p.shape,l),d=f[0],m=kG({inputs:{x:p},backend:n,attrs:{shape:[-1,fv(f[1])]}}),v=TG(m,m.dtype,"any",n);return h=kG(o?{inputs:{x:v},backend:n,attrs:{shape:kk(d,u)}}:{inputs:{x:v},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v),null!=c&&n.disposeIntermediateTensorInfo(p),h}},KG=function(e,t,n){this.variableNames=["A"];var r=e.windowSize,a=e.batchSize,i=e.outSize;n||this.variableNames.push("bestIndicesA"),this.outputShape=[a,i];var o="max"===t?">":"<",s=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode="\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = outIdx * "+r+";\n\n        int bestIndex = inOffset;\n        float bestValue = getA(batch, bestIndex);\n\n        for (int i = 0; i < "+r+"; i++) {\n          int inIdx = "+s+";\n          float candidate = getA(batch, inIdx);\n          if (candidate "+o+" bestValue) {\n            bestValue = candidate;\n            bestIndex = inIdx;\n          }\n        }\n        setOutput(float(bestIndex));\n      }\n    "},XG=function(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,lv(e.length>2,(function(){return"Packed arg"+(n.charAt(0).toUpperCase()+n.slice(1))+" supports only inputs with rank above 2."}));var a=e[e.length-1],i=Math.ceil(a/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),r||this.variableNames.push("bestIndicesA");var o,s,u=this.outputShape,l=u.length,c=iU(l),p=PU("coords",l);if(1===i){var h=iU(s=l+1);o="\n        "+h+" sourceLocR = "+h+"("+p.join()+", 0);\n        ++"+p[l-1]+";\n        "+h+" sourceLocG = "+h+"("+p.join()+", 0);\n        ++"+p[l-2]+";\n        "+h+" sourceLocA = "+h+"("+p.join()+", 0);\n        --"+p[l-1]+";\n        "+h+" sourceLocB = "+h+"("+p.join()+", 0);\n        --"+p[l-2]+";"}else s=l,o="\n        "+c+" sourceLocR = coords;\n        ++"+p[l-1]+";\n        "+c+" sourceLocG = coords;\n        ++"+p[l-2]+";\n        "+c+" sourceLocA = coords;\n        --"+p[l-1]+";\n        "+c+" sourceLocB = coords;\n        --"+p[l-2]+";";var f=["x","y","z","w","u","v"].slice(0,s),d="."+f[s-1],m=f.map((function(e){return"int "+e})),v=PU("sourceLocR",s-1).concat("inIdx.r"),g=PU("sourceLocG",s-1).concat("inIdx.g"),y=PU("sourceLocB",s-1).concat("inIdx.b"),b=PU("sourceLocA",s-1).concat("inIdx.a"),x="max"===n?"greaterThan":"lessThan",w=r?"":"\n          inIdx = round(vec4(getBestIndicesAChannel("+v.join()+"),\n                             getBestIndicesAChannel("+g.join()+"),\n                             getBestIndicesAChannel("+y.join()+"),\n                             getBestIndicesAChannel("+b.join()+")));",k="vec4(\n            getAChannel("+v.join()+"),\n            hasNextCol ? getAChannel("+g.join()+") : 0.,\n            hasNextRow ? getAChannel("+y.join()+") : 0.,\n            hasNextRow && hasNextCol ? getAChannel("+b.join()+") : 0.)",N=r?"":"\n      float getBestIndicesAChannel("+m.join()+") {\n        return getChannel(getBestIndicesA("+f.join()+"),\n                                          vec2("+f.slice(-2).join()+"));\n      }";this.userCode="\n      float getAChannel("+m.join()+") {\n        return getChannel(getA("+f.join()+"),\n                               vec2("+f.slice(-2).join()+"));\n      }\n      "+N+"\n      void main() {\n        "+c+" coords = getOutputCoords();\n        bool hasNextCol = "+p[l-1]+" < "+(u[l-1]-1)+";\n        bool hasNextRow = "+p[l-2]+" < "+(u[l-2]-1)+";\n        "+o+"\n        ivec4 srcIdx = ivec4(sourceLocR"+d+", sourceLocG"+d+",\n          sourceLocB"+d+", sourceLocA"+d+") * "+t+";\n        ivec4 inIdx = srcIdx;\n        vec4 bestIndex = vec4(inIdx);\n        vec4 bestValue = "+k+";\n\n        for (int i = 0; i < "+t+"; i++) {\n          inIdx = srcIdx;\n          "+w+"\n          vec4 candidate = "+k+";\n          bvec4 nan = isnan(candidate);\n          bvec4 replace = bvec4(\n            vec4("+x+"(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n          bestValue = vec4(replace.x  ? candidate.x : bestValue.x,\n                           replace.y  ? candidate.y : bestValue.y,\n                           replace.z  ? candidate.z : bestValue.z,\n                           replace.w  ? candidate.w : bestValue.w);\n          bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n          srcIdx++;\n        }\n        setOutput(bestIndex);\n      }\n    "};function YG(e,t,n,r){var a=[n];if(Nk("arg"+r.charAt(0).toUpperCase()+r.slice(1),a,t.shape.length),!Xv().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){var i=[],o=wk(t.shape,a),s=o[0],u=fv(o[1]),l=kG({inputs:{x:t},backend:e,attrs:{shape:[-1,u]}});i.push(l);var c=function e(t,n,r,a){void 0===a&&(a=null);var i=n.shape[0],o=n.shape[1];null!=a&&(i=a.shape[0],o=a.shape[1]);var s=oT(o),u={windowSize:s,inSize:o,batchSize:i,outSize:Math.ceil(o/s)},l=new KG(u,r,null==a),c=[n];null!=a&&c.push(a);var p=t.runWebGLProgram(l,c,"int32");if(1===p.shape[1])return p;var h=e(t,n,r,p);return t.disposeIntermediateTensorInfo(p),h}(e,l,r);i.push(c);var p=kG({inputs:{x:c},backend:e,attrs:{shape:s}});return i.forEach((function(t){return e.disposeIntermediateTensorInfo(t)})),p}return function e(t,n,r,a){void 0===a&&(a=null);var i=null!=a?a.shape:n.shape,o=oT(i[i.length-1]),s=new XG(i,o,r,null==a),u=null==a?[n]:[n,a],l=t.runWebGLProgram(s,u,"int32");if(l.shape.length===n.shape.length){var c=e(t,n,r,l);return t.disposeIntermediateTensorInfo(l),c}return l}(e,t,r)}var JG={kernelName:"ArgMax",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=xv(r.axis,a.shape),o=Ik(i,a.shape.length),s=a,u=[];null!=o&&(s=FG({inputs:{x:a},backend:n,attrs:{perm:o}}),u.push(s),i=Tk(i.length,s.shape.length)),Nk("argMax",[i[0]],s.shape.length);var l=YG(n,s,i[0],"max");return u.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),l}};var ZG={kernelName:"ArgMin",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=xv(r.axis,a.shape),o=Ik(i,a.shape.length),s=a,u=[];null!=o&&(s=FG({inputs:{x:a},backend:n,attrs:{perm:o}}),u.push(s),i=Tk(i.length,s.shape.length)),Nk("argMin",[i[0]],s.shape.length);var l=YG(n,s,i[0],"min");return u.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),l}},QG={kernelName:"Asin",backendName:"webgl",kernelFunc:hG({opSnippet:"if (isnan(x)) return x;\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return asin(x);\n"})},$G={kernelName:"Asinh",backendName:"webgl",kernelFunc:hG({opSnippet:"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));"})},ej={kernelName:"Atan",backendName:"webgl",kernelFunc:hG({opSnippet:"if (isnan(x)) return x;\n  return atan(x);\n"})},tj={kernelName:"Atan2",backendName:"webgl",kernelFunc:fG({opSnippet:"\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return atan(a, b);\n",packedOpSnippet:"\n  vec4 result = atan(a, b);\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n"})},nj={kernelName:"Atanh",backendName:"webgl",kernelFunc:hG({opSnippet:"if (isnan(x)) return x;\n  if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;"})},rj=function(e,t,n,r,a){if(void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");var i=e.filterWidth,o=e.strideHeight,s=e.strideWidth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterHeight,p=e.effectiveFilterWidth,h=e.padInfo.top,f=e.padInfo.left;this.outputShape=e.outShape;var d="avg"===t,m="((batch  * "+e.inHeight+" + xR) * "+e.inWidth+" + xC) * "+e.inChannels+" + d",v="(xR * "+e.inWidth+" + xC) * "+e.inChannels+" + d",g="0.0";if(d||(g="-1.0 / 1e-20"),n){this.userCode="\n        const ivec2 strides = ivec2("+o+", "+s+");\n        const ivec2 pads = ivec2("+h+", "+f+");\n\n        void main() {\n          ivec4 coords = getOutputCoords();\n          int batch = coords[0];\n          int d = coords[3];\n\n          ivec2 xRCCorner = coords.yz * strides - pads;\n          int xRCorner = xRCCorner.x;\n          int xCCorner = xRCCorner.y;\n\n          // max/min x(?, ?, d) to get y(yR, yC, d).\n          // ? = to be determined\n          float minMaxValue = 0.0;\n          float minMaxValueFound = 0.0;\n          int minMaxPosition = 0;\n          float avgValue = 0.0;\n\n          for (int wR = 0; wR < "+c+";\n              wR += "+u+") {\n            int xR = xRCorner + wR;\n\n            if (xR < 0 || xR >= "+e.inHeight+") {\n              continue;\n            }\n\n            for (int wC = 0; wC < "+p+";\n                wC += "+l+") {\n              int xC = xCCorner + wC;\n\n              if (xC < 0 || xC >= "+e.inWidth+") {\n                continue;\n              }\n\n              float value = getX(batch, xR, xC, d);\n\n              // If a min / max value has already been found, use it. If not,\n              // use the current value.\n              float currMinMaxValue = mix(\n                  value, minMaxValue, minMaxValueFound);\n              if (value >= currMinMaxValue) {\n                minMaxValue = value;\n                minMaxValueFound = 1.0;\n                minMaxPosition = "+(r?a?m:v:"wR * "+p+" + wC")+";\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      "}else{var y=t+"("+t+"("+t+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===t&&(y="avgValue / count");var b=4*Math.floor(i/4),x=i%4,w="\n      if ("+d+") {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    ";this.userCode="\n      const ivec2 strides = ivec2("+o+", "+s+");\n      const ivec2 pads = ivec2("+h+", "+f+");\n      const float initializationValue = "+g+";\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float count = 0.0;\n\n      float getValue(int batch, int xR, int xC, int d) {\n        if (xC < 0 || xC >= "+e.inWidth+") {\n          return initializationValue;\n        }\n        count += 1.0;\n        return getX(batch, xR, xC, d);\n      }\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d = coords[3];\n\n        ivec2 xRCCorner = coords.yz * strides - pads;\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        // max/min x(?, ?, d) to get y(yR, yC, d).\n        // ? = to be determined\n        vec4 minMaxValue = vec4("+g+");\n        float avgValue = 0.0;\n        count = 0.0;\n\n        for (int wR = 0; wR < "+c+";\n            wR += "+u+") {\n          int xR = xRCorner + wR;\n\n          if (xR < 0 || xR >= "+e.inHeight+") {\n            continue;\n          }\n\n          for (int wC = 0; wC < "+b+"; wC += 4) {\n            int xC = xCCorner + wC * "+l+";\n\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + "+l+", d),\n              getValue(batch, xR, xC + 2 * "+l+", d),\n              getValue(batch, xR, xC + 3 * "+l+", d)\n            );\n\n            "+w+"\n          }\n\n          int xC = xCCorner + "+b+";\n          if ("+(1===x)+") {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              initializationValue,\n              initializationValue,\n              initializationValue\n            );\n\n            "+w+"\n          } else if ("+(2===x)+") {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + "+l+", d),\n              initializationValue,\n              initializationValue\n            );\n\n            "+w+"\n          } else if ("+(3===x)+") {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + "+l+", d),\n              getValue(batch, xR, xC + 2 * "+l+", d),\n              initializationValue\n            );\n\n            "+w+"\n          }\n        }\n        setOutput("+y+");\n      }\n    "}},aj=function(e,t,n,r,a){if(void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");var i=e.filterWidth,o=e.strideDepth,s=e.strideHeight,u=e.strideWidth,l=e.dilationDepth,c=e.dilationHeight,p=e.dilationWidth,h=e.effectiveFilterDepth,f=e.effectiveFilterHeight,d=e.effectiveFilterWidth,m=e.padInfo.front,v=e.padInfo.top,g=e.padInfo.left;this.outputShape=e.outShape;var y="avg"===t,b="0.0";if(y||(b="-1.0 / 1e-20"),n){this.userCode="\n        const ivec3 strides =\n            ivec3("+o+", "+s+", "+u+");\n        const ivec3 pads = ivec3("+m+", "+v+", "+g+");\n\n        void main() {\n          ivec5 coords = getOutputCoords();\n          int batch = coords.x;\n          int ch = coords.u;\n\n          ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n          int xDCorner = xCorner.x;\n          int xRCorner = xCorner.y;\n          int xCCorner = xCorner.z;\n\n          // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n          // ? = to be determined\n          float minMaxValue = 0.0;\n          float minMaxValueFound = 0.0;\n          int minMaxPosition = 0;\n\n          for (int wD = 0; wD < "+h+";\n              wD += "+l+") {\n            int xD = xDCorner + wD;\n\n            if (xD < 0 || xD >= "+e.inDepth+") {\n              continue;\n            }\n\n            for (int wR = 0; wR < "+f+";\n                wR += "+c+") {\n              int xR = xRCorner + wR;\n\n              if (xR < 0 || xR >= "+e.inHeight+") {\n                continue;\n              }\n\n              for (int wC = 0; wC < "+d+";\n                  wC += "+p+") {\n                int xC = xCCorner + wC;\n\n                if (xC < 0 || xC >= "+e.inWidth+") {\n                  continue;\n                }\n\n                float value = getX(batch, xD, xR, xC, ch);\n\n                // If a min / max value has already been found, use it. If not,\n                // use the current value.\n                float currMinMaxValue = mix(\n                    value, minMaxValue, minMaxValueFound);\n                if (value >= currMinMaxValue) {\n                  minMaxValue = value;\n                  minMaxValueFound = 1.0;\n                  minMaxPosition = "+(r?a?"(((batch * "+e.inDepth+" + xD) * "+e.inHeight+" + xR) * "+e.inWidth+" + xC) * "+e.inChannels+" + ch":"((xD * "+e.inHeight+" + xR) * "+e.inWidth+" + xC) * "+e.inChannels+" + ch":"wD * "+f+" * "+d+" +\n                      wR * "+d+" + wC")+";\n                }\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      "}else{var x=t+"("+t+"("+t+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===t&&(x="avgValue / count");var w=4*Math.floor(i/4),k=i%4,N="\n      if ("+y+") {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    ";this.userCode="\n      const ivec3 strides =\n        ivec3("+o+", "+s+", "+u+");\n      const ivec3 pads = ivec3("+m+", "+v+", "+g+");\n      const float initializationValue = "+b+";\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float count = 0.0;\n\n      float getValue(int batch, int xD, int xR, int xC, int ch) {\n        if (xC < 0 || xC >= "+e.inWidth+") {\n          return initializationValue;\n        }\n        count += 1.0;\n        return getX(batch, xD, xR, xC, ch);\n      }\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n        int xDCorner = xCorner.x;\n        int xRCorner = xCorner.y;\n        int xCCorner = xCorner.z;\n\n        // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n        // ? = to be determined\n        vec4 minMaxValue = vec4("+b+");\n        float avgValue = 0.0;\n        count = 0.0;\n\n        for (int wD = 0; wD < "+h+";\n            wD += "+l+") {\n          int xD = xDCorner + wD;\n\n          if (xD < 0 || xD >= "+e.inDepth+") {\n            continue;\n          }\n\n          for (int wR = 0; wR < "+f+";\n            wR += "+c+") {\n            int xR = xRCorner + wR;\n\n            if (xR < 0 || xR >= "+e.inHeight+") {\n              continue;\n            }\n\n            for (int wC = 0; wC < "+w+"; wC += 4) {\n              int xC = xCCorner + wC * "+p+";\n\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + "+p+", ch),\n                getValue(batch, xD, xR, xC + 2 * "+p+", ch),\n                getValue(batch, xD, xR, xC + 3 * "+p+", ch)\n              );\n\n              "+N+"\n            }\n\n            int xC = xCCorner + "+w+";\n            if ("+(1===k)+") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                initializationValue,\n                initializationValue,\n                initializationValue\n              );\n\n              "+N+"\n            } else if ("+(2===k)+") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + "+p+", ch),\n                initializationValue,\n                initializationValue\n              );\n\n              "+N+"\n            } else if ("+(3===k)+") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + "+p+", ch),\n                getValue(batch, xD, xR, xC + 2 * "+p+", ch),\n                initializationValue\n              );\n\n              "+N+"\n            }\n          }\n          setOutput("+x+");\n        }\n      }\n    "}};var ij={kernelName:"AvgPool",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;TV(a,"avgPool");var i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode;lv(Xx(o,1),(function(){return"Error in avgPool: Either strides or dilations must be 1. Got strides "+o+" and dilations '1'"}));var l=Px(a.shape,i,o,1,s,u);if(1===l.filterWidth&&1===l.filterHeight&&dv(l.inShape,l.outShape))return nG({inputs:{x:a},backend:n});var c=new rj(l,"avg",!1);return n.runWebGLProgram(c,[a],"float32")}};var oj={kernelName:"AvgPool3D",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode,l=r.dataFormat,c=Bx(a.shape,i,o,[1,1,1],s,u,l),p=new aj(c,"avg",!1);return n.runWebGLProgram(p,[a],"float32")}},sj=function(e){this.variableNames=["dy"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=e.dilationHeight,o=e.dilationWidth,s=e.effectiveFilterHeight,u=e.effectiveFilterWidth,l=s-1-e.padInfo.top,c=u-1-e.padInfo.left,p=1/(t*n);this.userCode="\n      const ivec2 pads = ivec2("+l+", "+c+");\n      const float avgMultiplier = float("+p+");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n\n        ivec2 dyRCCorner = coords.yz - pads;\n        int dyRCorner = dyRCCorner.x;\n        int dyCCorner = dyRCCorner.y;\n\n        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < "+s+";\n            wR += "+i+") {\n          float dyR = float(dyRCorner + wR) / "+r+".0;\n\n          if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          for (int wC = 0; wC < "+u+";\n            wC+= "+o+") {\n            float dyC = float(dyCCorner + wC) / "+a+".0;\n\n            if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            float dyValue = getDy(b, idyR, idyC, d);\n\n            dotProd += dyValue * avgMultiplier;\n          }\n        }\n        setOutput(dotProd);\n      }\n    "},uj=function(e){this.variableNames=["dy"],this.outputShape=e.inShape;var t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,o=e.strideWidth,s=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterDepth,p=e.effectiveFilterHeight,h=e.effectiveFilterWidth,f=c-1-e.padInfo.front,d=p-1-e.padInfo.top,m=h-1-e.padInfo.left,v=1/(t*n*r);this.userCode="\n      const ivec3 pads = ivec3("+f+", "+d+", "+m+");\n      const float avgMultiplier = float("+v+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n        // dx(xD, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < "+c+";\n            wD += "+s+") {\n          float dyD = float(dyDCorner + wD) / "+a+".0;\n\n          if (dyD < 0.0 || dyD >= "+e.outDepth+".0 || fract(dyD) > 0.0) {\n            continue;\n          }\n          int idyD = int(dyD);\n\n          for (int wR = 0; wR < "+p+";\n              wR += "+u+") {\n            float dyR = float(dyRCorner + wR) / "+i+".0;\n\n            if (dyR < 0.0 || dyR >= "+e.outHeight+".0 ||\n                fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            for (int wC = 0; wC < "+h+";\n                wC += "+l+") {\n              float dyC = float(dyCCorner + wC) / "+o+".0;\n\n              if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n              dotProd += dyValue * avgMultiplier;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    "};var lj={kernelName:"AvgPool3DGrad",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=r.filterSize,s=r.strides,u=r.pad,l=r.dimRoundingMode,c=Bx(i.shape,o,s,[1,1,1],u,l),p=new uj(c);return n.runWebGLProgram(p,[a],i.dtype)}};var cj={kernelName:"AvgPoolGrad",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=i;TV([a,i],"avgPoolGrad");var s=r.filterSize,u=r.strides,l=r.pad,c=Px(o.shape,s,u,1,l),p=new sj(c);return n.runWebGLProgram(p,[a],o.dtype)}};var pj={kernelName:"BatchMatMul",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs;return OG({a:t.a,b:t.b,transposeA:r.transposeA,transposeB:r.transposeB,backend:n})}},hj=function(e,t,n,r,a,i){this.outputShape=[],this.variableNames=["x","mean","variance"],Ow(e,t),Ow(e,n);var o="0.0";null!=r&&(Ow(e,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");var s="1.0";null!=a&&(Ow(e,a),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=e,this.userCode="\n      void main() {\n        float x = getXAtOutCoords();\n        float mean = getMeanAtOutCoords();\n        float variance = getVarianceAtOutCoords();\n        float offset = "+o+";\n        float scale = "+s+";\n        float inv = scale * inversesqrt(variance + float("+i+"));\n        setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n      }\n    "},fj=function(e,t,n,r,a,i){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],Ow(e,t),Ow(e,n);var o="vec4(0.0)";null!=r&&(Ow(e,r),this.variableNames.push("offset"),o="getOffsetAtOutCoords()");var s="vec4(1.0)";null!=a&&(Ow(e,a),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=e,this.userCode="\n      void main() {\n        vec4 offset = "+o+";\n        vec4 scale = "+s+";\n\n        vec4 x = getXAtOutCoords();\n        vec4 mean = getMeanAtOutCoords();\n        vec4 variance = getVarianceAtOutCoords();\n\n        vec4 inv = scale * inversesqrt(variance + vec4("+i+"));\n\n        setOutput((x - mean) * inv + offset);\n      }\n    "},dj={kernelName:"FusedBatchNorm",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.mean,o=t.variance,s=t.offset,u=t.scale;lv(i.shape.length===o.shape.length,(function(){return"Batch normalization gradient requires mean and variance to have equal ranks."})),lv(null==s||i.shape.length===s.shape.length,(function(){return"Batch normalization gradient requires mean and offset to have equal ranks."})),lv(null==u||i.shape.length===u.shape.length,(function(){return"Batch normalization gradient requires mean and scale to have equal ranks."}));var l=r.varianceEpsilon;null==l&&(l=.001);var c=[a,i,o],p=null;null!=s&&(p=s.shape,c.push(s));var h=null;null!=u&&(h=u.shape,c.push(u));var f=Xv().getBool("WEBGL_PACK_NORMALIZATION")?new fj(a.shape,i.shape,o.shape,p,h,l):new hj(a.shape,i.shape,o.shape,p,h,l);return n.runWebGLProgram(f,c,c[0].dtype)}},mj=function(){function e(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;var t,n=iU(this.rank),r="uniform int start["+this.rank+"];",a=function(e){if(1===e)return"sourceLoc";if(e<=6)return vj.slice(0,e).map((function(e){return"sourceLoc."+e})).join(",");throw Error("Slicing for rank "+e+" is not yet supported")}(this.rank);t="\n        "+n+" sourceLoc;\n        "+n+" coords = getOutputCoords();\n        "+e.map((function(e,t){return"sourceLoc."+vj[t]+" = start["+t+"] + coords."+vj[t]+";"})).join("\n")+"\n      ",this.userCode="\n      "+r+"\n      void main() {\n        "+t+"\n        setOutput(getSource("+a+"));\n      }\n    "}return e.prototype.getCustomSetupFunc=function(e){var t=this;if(e.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the length of start ("+e.length+")");return function(n,r){null==t.startLoc&&(t.startLoc=n.getUniformLocationNoThrow(r,"start"),null==t.startLoc)||n.gl.uniform1iv(t.startLoc,e)}},e}(),vj=["x","y","z","w","u","v"];var gj=function(){function e(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length;var t=iU(this.rank),n=PU("coords",this.rank),r=PU("sourceLoc",this.rank),a=1===this.rank?"sourceLoc":"vec2("+r.slice(-2).join()+")",i="getChannel(getSource("+r.join()+"), "+a+")",o="\n      result.x = "+i+";\n      if (++"+n[this.rank-1]+" < "+e[this.rank-1]+") {\n        ++"+r[this.rank-1]+";\n        result.y = "+i+";\n        --"+r[this.rank-1]+";\n      }\n    ",s=1===this.rank?"":"\n      --"+n[this.rank-1]+";\n      if (++"+n[this.rank-2]+" < "+e[this.rank-2]+") {\n        ++"+r[this.rank-2]+";\n        result.z = "+i+";\n        if (++"+n[this.rank-1]+" < "+e[this.rank-1]+") {\n          ++"+r[this.rank-1]+";\n          result.w = "+i+";\n        }\n      }\n    ",u=this.rank<=4?"sourceLoc = coords +\n            "+t+"("+e.map((function(e,t){return"start["+t+"]"})).join()+");":e.map((function(e,t){return r[t]+" = "+n[t]+" + start["+t+"];"})).join("\n");this.userCode="\n      uniform int start["+this.rank+"];\n      void main() {\n        "+t+" coords = getOutputCoords();\n        "+t+" sourceLoc;\n        "+u+"\n        vec4 result = vec4(0.);\n        "+o+"\n        "+s+"\n        setOutput(result);\n      }\n    "}return e.prototype.getCustomSetupFunc=function(e){var t=this;if(e.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the length of start ("+e.length+")");return function(n,r){null==t.startLoc&&(t.startLoc=n.getUniformLocationNoThrow(r,"start"),null==t.startLoc)||n.gl.uniform1iv(t.startLoc,e)}},e}();function yj(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=$b(a,r.begin,r.size),o=i[0],s=i[1];if(Bb(a,o,s),0===fv(s))return n.makeTensorInfo(s,a.dtype,[]);if(n.shouldExecuteOnCPU([a])||"string"===a.dtype){var u=n.texData.get(a.dataId),l=AU(u.values,o,s,a.shape,a.dtype);return n.makeTensorInfo(s,a.dtype,l)}var c=n.texData.get(a.dataId).isPacked,p=Zb(a.shape,o,s);if(c||!p){var h=Xv().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new gj(s):new mj(s),f=h.getCustomSetupFunc(o);return n.runWebGLProgram(h,[a],a.dtype,f)}return n.uploadToGPU(a.dataId),function(e,t,n,r){var a=r.texData.get(e.dataId),i=r.makeTensorInfo(n,e.dtype),o=r.texData.get(i.dataId);Object.assign(o,a),o.shape=n,o.dtype=e.dtype;var s=Qb(t,Lv(e.shape));a.slice&&(s+=a.slice.flatOffset),o.slice={flatOffset:s,origDataId:a.slice&&a.slice.origDataId||e.dataId};var u=r.dataRefCount.get(o.slice.origDataId)||1;return r.dataRefCount.set(o.slice.origDataId,u+1),i}(a,o,s,n)}var bj={kernelName:"Slice",backendName:"webgl",kernelFunc:yj},xj={kernelName:"BatchToSpaceND",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockShape,o=r.crops;lv(a.shape.length<=4,(function(){return"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"}));var s=i.reduce((function(e,t){return e*t})),u=uT(a.shape,i,s),l=lT(u.length,i.length),c=cT(a.shape,i,s),p=pT(o,i.length),h=hT(c,o,i.length),f=[],d=kG({inputs:{x:a},backend:n,attrs:{shape:u}}),m=FG({inputs:{x:d},backend:n,attrs:{perm:l}}),v=kG({inputs:{x:m},backend:n,attrs:{shape:c}}),g=yj({inputs:{x:v},backend:n,attrs:{begin:p,size:h}});return f.push(d),f.push(m),f.push(v),f.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),g}};var wj={kernelName:"Bincount",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.weights,o=r.size,s=n.texData.get(a.dataId).values,u=n.texData.get(i.dataId).values,l=cU(s,u,i.dtype,i.shape,o);return n.makeTensorInfo([o],i.dtype,l)}},kj=fG({opSnippet:"return float(a != b);",dtype:"bool"}),Nj={kernelName:"NotEqual",backendName:"webgl",kernelFunc:kj};function Ij(e){var t=e.inputs,n=e.backend,r=t.input;return nG({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}var Sj={kernelName:"Real",backendName:"webgl",kernelFunc:Ij};var Tj={kernelName:"Cast",backendName:"webgl",kernelFunc:function e(t){var n=t.inputs,r=t.backend,a=t.attrs,i=n.x,o=a.dtype;if("complex64"===o){if("complex64"===i.dtype)return nG({inputs:{x:i},backend:r});var s=qk(i.shape),u=e({inputs:{x:i},backend:r,attrs:{dtype:"float32"}}),l=aG({inputs:{real:u,imag:s},backend:r});return s.dispose(),r.disposeIntermediateTensorInfo(u),l}if("complex64"===i.dtype){var c=Ij({inputs:{input:i},backend:r}),p=e({inputs:{x:c},backend:r,attrs:{dtype:o}});return r.disposeIntermediateTensorInfo(c),p}if(!Tv(i.dtype,o)){var h=nG({inputs:{x:i},backend:r});return{dataId:h.dataId,shape:h.shape,dtype:o}}if("int32"===o)return function(e,t){var n=new HU(e.shape,"return float(int(x));"),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}(i,r);if("bool"===o){var f=r.makeTensorInfo([],"bool",kv("bool",1)),d=kj({inputs:{a:i,b:f},backend:r});return r.disposeIntermediateTensorInfo(f),d}throw new Error("Error in Cast: failed to cast "+i.dtype+" to "+o)}},Cj="return ceil(x);",Ej={kernelName:"Ceil",backendName:"webgl",kernelFunc:hG({opSnippet:Cj,packedOpSnippet:Cj,cpuKernelImpl:hU})},Rj=function(){function e(e){this.variableNames=["A"],this.outputShape=e,this.userCode="\n      uniform float minVal;\n      uniform float maxVal;\n\n      void main() {\n        float value = getAAtOutCoords();\n        if (isnan(value)) {\n          setOutput(value);\n          return;\n        }\n\n        setOutput(clamp(value, minVal, maxVal));\n      }\n    "}return e.prototype.getCustomSetupFunc=function(e,t){var n=this;return function(r,a){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(a,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(a,"maxVal")),r.gl.uniform1f(n.minLoc,e),r.gl.uniform1f(n.maxLoc,t)}},e}(),Aj=function(){function e(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.userCode="\n      uniform float minVal;\n      uniform float maxVal;\n\n      void main() {\n        vec4 value = getAAtOutCoords();\n\n        if (any(isnan(value))) {\n          setOutput(value);\n          return;\n        }\n\n        setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n      }\n    "}return e.prototype.getCustomSetupFunc=function(e,t){var n=this;return function(r,a){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(a,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(a,"maxVal")),r.gl.uniform1f(n.minLoc,e),r.gl.uniform1f(n.maxLoc,t)}},e}();var Dj={kernelName:"ClipByValue",backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=a.clipValueMin,s=a.clipValueMax,u=(t=Xv().getBool("WEBGL_PACK_CLIP")?new Aj(i.shape):new Rj(i.shape)).getCustomSetupFunc(o,s);return r.runWebGLProgram(t,[i],i.dtype,u)}},Fj=function(e){this.variableNames=["real","imag"],this.outputShape=e,this.userCode="\n      void main() {\n        float re = abs(getRealAtOutCoords());\n        float im = abs(getImagAtOutCoords());\n        float mx = max(re, im);\n\n        // sadly the length function in glsl is not underflow-safe\n        // (at least not on Intel GPUs). So the safe solution is\n        // to ensure underflow-safety in all cases.\n        setOutput(\n          mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n        );\n      }\n    "};function _j(e,t){return{dataId:t.dataId,dtype:t.dtype,shape:e.shape}}var Oj={kernelName:"ComplexAbs",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,a=n.texData.get(r.dataId),i=new Fj(r.shape),o=[_j(r,a.complexTensorInfos.real),_j(r,a.complexTensorInfos.imag)];return n.runWebGLProgram(i,o,o[0].dtype)}},Mj=function(e){this.outputShape=[],this.outputShape=iT(e,1),this.variableNames=e.map((function(e,t){return"T"+t}));var t=new Array(e.length-1);t[0]=e[0][1];for(var n=1;n<t.length;n++)t[n]=t[n-1]+e[n][1];for(var r=["if (yC < "+t[0]+") setOutput(getT0(yR, yC));"],a=1;a<t.length;a++){var i=t[a-1];r.push("else if (yC < "+t[a]+") setOutput(getT"+a+"(yR, yC-"+i+"));")}var o=t.length,s=t[t.length-1];r.push("else setOutput(getT"+o+"(yR, yC-"+s+"));"),this.userCode="\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int yR = coords.x;\n        int yC = coords.y;\n\n        "+r.join("\n        ")+"\n      }\n    "},Lj=function(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=iT(e,t);var n=this.outputShape,r=n.length,a=iU(r),i=PU("coords",r),o=["x","y","z","w","u","v"].slice(0,r);this.variableNames=e.map((function(e,t){return"T"+t}));var s=new Array(e.length-1);s[0]=e[0][t];for(var u=1;u<s.length;u++)s[u]=s[u-1]+e[u][t];for(var l=o[t],c=o.slice(-2),p=o.join(),h="if ("+l+" < "+s[0]+") {\n        return getChannel(\n            getT0("+p+"), vec2("+c.join()+"));\n        }",f=1;f<s.length;f++){var d=s[f-1];h+="\n        if ("+l+" < "+s[f]+"  && "+l+" >= "+s[f-1]+") {\n          return getChannel(\n            getT"+f+"("+zj(o,l,d)+"),\n            vec2("+zj(c,l,d)+"));\n        }"}var m=s.length,v=s[s.length-1];h+="\n        return getChannel(\n          getT"+m+"("+zj(o,l,v)+"),\n          vec2("+zj(c,l,v)+"));",this.userCode="\n      float getValue("+o.map((function(e){return"int "+e}))+") {\n        "+h+"\n      }\n\n      void main() {\n        "+a+" coords = getOutputCoords();\n        vec4 result = vec4(getValue("+i+"), 0., 0., 0.);\n\n        "+i[r-1]+" = "+i[r-1]+" + 1;\n        if ("+i[r-1]+" < "+n[r-1]+") {\n          result.g = getValue("+i+");\n        }\n\n        "+i[r-2]+" = "+i[r-2]+" + 1;\n        if ("+i[r-2]+" < "+n[r-2]+") {\n          result.a = getValue("+i+");\n        }\n\n        "+i[r-1]+" = "+i[r-1]+" - 1;\n        if ("+i[r-2]+" < "+n[r-2]+" &&\n            "+i[r-1]+" < "+n[r-1]+") {\n          result.b = getValue("+i+");\n        }\n        setOutput(result);\n      }\n    "};function zj(e,t,n){var r=e.indexOf(t);return e.map((function(e,t){return t===r?e+" - "+n:e})).join()}function Pj(e){var t=e.inputs,n=e.backend,r=t.input;return nG({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}var Bj={kernelName:"Imag",backendName:"webgl",kernelFunc:Pj};function Wj(e){var t=e.inputs,n=e.backend,r=xv(e.attrs.axis,t[0].shape)[0],a=iT(t.map((function(e){return e.shape})),r);if(0===fv(a))return n.makeTensorInfo(a,t[0].dtype,[]);var i=t.filter((function(e){return fv(e.shape)>0}));return 1===i.length?nG({inputs:{x:i[0]},backend:n}):(aT(i.map((function(e){return e.shape})),r),function e(t,n,r){var a=t[0].dtype;if("complex64"===a){var i=t.map((function(e){return Ij({inputs:{input:e},backend:r})})),o=t.map((function(e){return Pj({inputs:{input:e},backend:r})})),s=e(i,n,r),u=e(o,n,r),l=aG({inputs:{real:s,imag:u},backend:r});return i.forEach((function(e){return r.disposeIntermediateTensorInfo(e)})),o.forEach((function(e){return r.disposeIntermediateTensorInfo(e)})),r.disposeIntermediateTensorInfo(s),r.disposeIntermediateTensorInfo(u),l}if(t.length>Xv().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){var c=Math.floor(t.length/2),p=e(t.slice(0,c),n,r),h=e(t.slice(c),n,r),f=e([p,h],n,r);return r.disposeIntermediateTensorInfo(p),r.disposeIntermediateTensorInfo(h),f}if(Xv().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&t[0].shape.length>1){var d=new Lj(t.map((function(e){return e.shape})),n);return r.runWebGLProgram(d,t,a)}var m=iT(t.map((function(e){return e.shape})),n),v=t.map((function(e){return kG({inputs:{x:e},attrs:{shape:[-1,fv(e.shape.slice(n))]},backend:r})})),g=new Mj(v.map((function(e){return e.shape}))),y=r.runWebGLProgram(g,v,a);v.forEach((function(e){return r.disposeIntermediateTensorInfo(e)}));var b=kG({inputs:{x:y},attrs:{shape:m},backend:r});return r.disposeIntermediateTensorInfo(y),b}(i,r,n))}var Vj={kernelName:"Concat",backendName:"webgl",kernelFunc:Wj},Uj=function(e,t,n,r,a){void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x","W"],this.outputShape=e.outShape;var i=e.padInfo.top,o=e.padInfo.left,s=e.strideHeight,u=e.strideWidth,l=e.dilationHeight,c=e.dilationWidth,p=e.filterHeight,h=e.filterWidth,f=4*Math.floor(e.inChannels/4),d=e.inChannels%4,m="channelsLast"===e.dataFormat,v=m?1:2,g=m?2:3,y=m?3:1,b="",x="";n&&(b=r?"float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          "+n+"\n        }":a?"float activation(float a) {\n          float b = getLeakyreluAlphaAtOutCoords();\n          "+n+"\n        }":"\n          float activation(float x) {\n            "+n+"\n          }\n        ",x="result = activation(result);");var w=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode="\n      "+b+"\n\n      const ivec2 strides = ivec2("+s+", "+u+");\n      const ivec2 pads = ivec2("+i+", "+o+");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d2 = coords["+y+"];\n\n        ivec2 xRCCorner =\n            ivec2(coords["+v+"], coords["+g+"]) * strides - pads;\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < "+p+"; wR++) {\n          int xR = xRCorner + wR * "+l+";\n\n          if (xR < 0 || xR >= "+e.inHeight+") {\n            continue;\n          }\n\n          for (int wC = 0; wC < "+h+"; wC++) {\n            int xC = xCCorner + wC * "+c+";\n\n            if (xC < 0 || xC >= "+e.inWidth+") {\n              continue;\n            }\n\n            for (int d1 = 0; d1 < "+f+"; d1 += 4) {\n              vec4 wValues = vec4(\n                getW(wR, wC, d1, d2),\n                getW(wR, wC, d1 + 1, d2),\n                getW(wR, wC, d1 + 2, d2),\n                getW(wR, wC, d1 + 3, d2)\n              );\n\n              if ("+m+") {\n                vec4 xValues = vec4(\n                  getX(batch, xR, xC, d1),\n                  getX(batch, xR, xC, d1 + 1),\n                  getX(batch, xR, xC, d1 + 2),\n                  getX(batch, xR, xC, d1 + 3)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec4 xValues = vec4(\n                  getX(batch, d1, xR, xC),\n                  getX(batch, d1 + 1, xR, xC),\n                  getX(batch, d1 + 2, xR, xC),\n                  getX(batch, d1 + 3, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n            }\n\n            if ("+(1===d)+") {\n\n              if ("+m+") {\n                dotProd +=\n                    getX(batch, xR, xC, "+f+") *\n                    getW(wR, wC, "+f+", d2);\n              } else {\n                dotProd +=\n                    getX(batch, "+f+", xR, xC) *\n                    getW(wR, wC, "+f+", d2);\n              }\n\n            } else if ("+(2===d)+") {\n              vec2 wValues = vec2(\n                getW(wR, wC, "+f+", d2),\n                getW(wR, wC, "+f+" + 1, d2)\n              );\n\n              if ("+m+") {\n                vec2 xValues = vec2(\n                  getX(batch, xR, xC, "+f+"),\n                  getX(batch, xR, xC, "+f+" + 1)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec2 xValues = vec2(\n                  getX(batch, "+f+", xR, xC),\n                  getX(batch, "+f+" + 1, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n\n            } else if ("+(3===d)+") {\n              vec3 wValues = vec3(\n                getW(wR, wC, "+f+", d2),\n                getW(wR, wC, "+f+" + 1, d2),\n                getW(wR, wC, "+f+" + 2, d2)\n              );\n\n              if ("+m+") {\n                vec3 xValues = vec3(\n                  getX(batch, xR, xC, "+f+"),\n                  getX(batch, xR, xC, "+f+" + 1),\n                  getX(batch, xR, xC, "+f+" + 2)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec3 xValues = vec3(\n                  getX(batch, "+f+", xR, xC),\n                  getX(batch, "+f+" + 1, xR, xC),\n                  getX(batch, "+f+" + 2, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n\n            }\n          }\n        }\n\n        float result = dotProd;\n        "+w+"\n        "+x+"\n        setOutput(result);\n      }\n    "},Gj=function(e){this.variableNames=["x","W"],this.outputShape=e.outShape;var t=e.padInfo.front,n=e.padInfo.top,r=e.padInfo.left,a=e.strideDepth,i=e.strideHeight,o=e.strideWidth,s=e.dilationDepth,u=e.dilationHeight,l=e.dilationWidth,c=e.filterDepth,p=e.filterHeight,h=e.filterWidth,f=4*Math.floor(e.inChannels/4),d=e.inChannels%4;this.userCode="\n      const ivec3 strides = ivec3("+a+", "+i+", "+o+");\n      const ivec3 pads = ivec3("+t+", "+n+", "+r+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d2 = coords.u;\n\n        ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n        int xFCorner = xFRCCorner.x;\n        int xRCorner = xFRCCorner.y;\n        int xCCorner = xFRCCorner.z;\n\n        // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n        // y(yF, yR, yC, d2). ? = to be determined. : = across all\n        // values in that axis.\n        float dotProd = 0.0;\n        for (int wF = 0; wF < "+c+"; wF++) {\n          int xF = xFCorner + wF * "+s+";\n\n          if (xF < 0 || xF >= "+e.inDepth+") {\n            continue;\n          }\n\n          for (int wR = 0; wR < "+p+"; wR++) {\n            int xR = xRCorner + wR * "+u+";\n\n            if (xR < 0 || xR >= "+e.inHeight+") {\n              continue;\n            }\n\n            for (int wC = 0; wC < "+h+"; wC++) {\n              int xC = xCCorner + wC * "+l+";\n\n              if (xC < 0 || xC >= "+e.inWidth+") {\n                continue;\n              }\n\n              for (int d1 = 0; d1 < "+f+"; d1 += 4) {\n                vec4 xValues = vec4(\n                  getX(batch, xF, xR, xC, d1),\n                  getX(batch, xF, xR, xC, d1 + 1),\n                  getX(batch, xF, xR, xC, d1 + 2),\n                  getX(batch, xF, xR, xC, d1 + 3)\n                );\n                vec4 wValues = vec4(\n                  getW(wF, wR, wC, d1, d2),\n                  getW(wF, wR, wC, d1 + 1, d2),\n                  getW(wF, wR, wC, d1 + 2, d2),\n                  getW(wF, wR, wC, d1 + 3, d2)\n                );\n\n                dotProd += dot(xValues, wValues);\n              }\n\n              if ("+(1===d)+") {\n                dotProd +=\n                  getX(batch, xF, xR, xC, "+f+") *\n                  getW(wF, wR, wC, "+f+", d2);\n              } else if ("+(2===d)+") {\n                vec2 xValues = vec2(\n                  getX(batch, xF, xR, xC, "+f+"),\n                  getX(batch, xF, xR, xC, "+f+" + 1)\n                );\n                vec2 wValues = vec2(\n                  getW(wF, wR, wC, "+f+", d2),\n                  getW(wF, wR, wC, "+f+" + 1, d2)\n                );\n                dotProd += dot(xValues, wValues);\n              } else if ("+(3===d)+") {\n                vec3 xValues = vec3(\n                  getX(batch, xF, xR, xC, "+f+"),\n                  getX(batch, xF, xR, xC, "+f+" + 1),\n                  getX(batch, xF, xR, xC, "+f+" + 2)\n                );\n                vec3 wValues = vec3(\n                  getW(wF, wR, wC, "+f+", d2),\n                  getW(wF, wR, wC, "+f+" + 1, d2),\n                  getW(wF, wR, wC, "+f+" + 2, d2)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    "},jj=function(e,t,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;for(var r=n.filterWidth,a=n.inChannels,i=n.strideWidth,o=n.strideHeight,s=n.padInfo,u=n.outWidth,l=n.dilationWidth,c=n.dilationHeight,p=n.dataFormat,h=s.left,f=s.top,d=a*r,m=EV(),v="channelsLast"===p,g=v?0:1,y=v?1:2,b="",x=0;x<=1;x++)for(var w=0;w<=1;w++)b+="\n          blockIndex = rc.y + "+w+";\n          pos = rc.x + "+x+";\n\n          if(blockIndex < "+e[1]+" && pos < "+e[0]+") {\n            offsetY = int(blockIndex / ("+u+")) * "+o+" - "+f+";\n            d0 = offsetY + "+c+" * (pos / "+d+");\n\n            if(d0 < "+t[g]+" && d0 >= 0) {\n\n              offsetX = int(mod(float(blockIndex), "+u+".) * "+i+". - "+h+".);\n              d1 = offsetX + "+l+" * (int(mod(float(pos), "+d+".) / "+a+".));\n\n              if(d1 < "+t[y]+" && d1 >= 0) {\n\n                ch = int(mod(float(pos), "+a+".));\n\n                if ("+v+") {\n                  innerDims = vec2(d1, ch);\n                  result["+(2*x+w)+"] = getChannel(\n                    getA(d0, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                } else {\n                  innerDims = vec2(d0, d1);\n                  result["+(2*x+w)+"] = getChannel(\n                    getA(ch, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                }\n              }\n            }\n          }\n        ";this.userCode="\n      void main() {\n        ivec2 rc = getOutputCoords();\n\n        vec4 result = vec4(0);\n\n        int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n        vec2 innerDims;\n\n        "+b+"\n\n        "+m.output+" = result;\n      }\n    "};function Hj(e){var t,n=e.x,r=e.filter,a=e.convInfo,i=e.backend,o=e.bias,s=void 0===o?null:o,u=e.preluActivationWeights,l=void 0===u?null:u,c=e.leakyreluAlpha,p=void 0===c?0:c,h=e.activation,f=void 0===h?null:h,d=n.shape,m=i.texData.get(n.dataId),v=a.inChannels,g=d[0]*d[1]*d[2],y=a.outChannels,b="channelsLast"===a.dataFormat,x=[],w=(1===g||1===y)&&v>1e3,k=d[2]%2!=0&&!!m.isPacked;if(!w&&Xv().getBool("WEBGL_LAZILY_UNPACK")&&Xv().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&k){var N=b?d[0]*d[1]*(d[2]+1):d[0]*d[2]*(d[3]+1),I={dataId:n.dataId,shape:[1,N,a.inChannels],dtype:n.dtype},S=m.shape;m.shape=m.shape.slice(),m.shape[m.shape.length-2]++,lv(wV(m.shape,I.shape),(function(){return"packed reshape "+m.shape+" to "+I.shape+" isn't free"}));var T=kG({inputs:{x:r},backend:i,attrs:{shape:[1,a.inChannels,a.outChannels]}});x.push(T);var C=OG({a:I,b:T,backend:i,transposeA:!1,transposeB:!1,bias:s,activation:f,preluActivationWeights:l,leakyreluAlpha:p}),E=i.texData.get(C.dataId);lv(E.isPacked,(function(){return"batchMatMul result is expected to be packed"})),m.shape=S,E.shape=a.outShape,(t=nG({inputs:{x:C},backend:i})).shape=a.outShape,x.push(C)}else{var R=kG({inputs:{x:n},backend:i,attrs:{shape:[1,b?d[0]*d[1]*d[2]:d[0]*d[2]*d[3],a.inChannels]}}),A=kG({inputs:{x:r},backend:i,attrs:{shape:[1,a.inChannels,a.outChannels]}}),D=OG({a:R,b:A,transposeA:!1,transposeB:!1,backend:i,bias:s,activation:f,preluActivationWeights:l,leakyreluAlpha:p});t=kG({inputs:{x:D},backend:i,attrs:{shape:a.outShape}}),x.push(R),x.push(A),x.push(D)}for(var F=0,_=x;F<_.length;F++){var O=_[F];i.disposeIntermediateTensorInfo(O)}return t}function qj(e){var t=e.x,n=e.filter,r=e.convInfo,a=e.backend,i=e.bias,o=void 0===i?null:i,s=e.preluActivationWeights,u=void 0===s?null:s,l=e.leakyreluAlpha,c=void 0===l?0:l,p=e.activation,h=void 0===p?null:p,f=r.filterWidth,d=r.filterHeight,m=r.inChannels,v=r.outWidth,g=r.outHeight,y="channelsLast"===r.dataFormat,b=f*d*m,x=g*v,w=[b,x],k=[],N=kG({inputs:{x:t},backend:a,attrs:{shape:t.shape.slice(1)}}),I=kG({inputs:{x:n},backend:a,attrs:{shape:[1,b,fv(n.shape)/b]}});k.push(N),k.push(I);var S=new jj(w,N.shape,r),T=a.runWebGLProgram(S,[N],"float32"),C=kG({inputs:{x:T},backend:a,attrs:{shape:[1,w[0],w[1]]}});k.push(T),k.push(C);var E=null!=o,R=null!=u,A="leakyrelu"===h,D=h?dG(h,!0):null,F=new mG(C.shape,I.shape,[1,x,r.outChannels],!0,!1,E,D,R,A),_=[C,I];if(o&&_.push(o),R&&_.push(u),A){var O=a.makeTensorInfo([],"float32",vg(c,"float32"));_.push(O),k.push(O)}var M=a.runWebGLProgram(F,_,"float32"),L=kG({inputs:{x:M},backend:a,attrs:{shape:y?[1,g,v,r.outChannels]:[1,r.outChannels,g,v]}});k.push(M);for(var z=0,P=k;z<P.length;z++){var B=P[z];a.disposeIntermediateTensorInfo(B)}return L}var Kj={kernelName:"Conv2D",backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=n.filter,s=a.strides,u=a.pad,l=a.dataFormat,c=a.dilations,p=a.dimRoundingMode,h=Yx(l),f=Wx(i.shape,o.shape,s,c,u,p,!1,h);if(1!==f.filterHeight||1!==f.filterWidth||1!==f.dilationHeight||1!==f.dilationWidth||1!==f.strideHeight||1!==f.strideWidth||"SAME"!==f.padInfo.type&&"VALID"!==f.padInfo.type)if(Xv().getBool("WEBGL_CONV_IM2COL")&&1===i.shape[0])t=qj({x:i,filter:o,convInfo:f,backend:r});else{var d=new Uj(f);t=r.runWebGLProgram(d,[i,o],"float32")}else t=Hj({x:i,filter:o,convInfo:f,backend:r});var m=kG({inputs:{x:t},backend:r,attrs:{shape:f.outShape}});return r.disposeIntermediateTensorInfo(t),m}},Xj=function(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;var t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i="channelsLast"===e.dataFormat;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int d2 = coords.w;\n\n        // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int b = 0; b < "+e.batchSize+"; b++) {\n          for (int yR = 0; yR < "+e.outHeight+"; yR++) {\n            int xR = wR + yR * "+t+" - "+r+";\n\n            if (xR < 0 || xR >= "+e.inHeight+") {\n              continue;\n            }\n\n            for (int yC = 0; yC < "+e.outWidth+"; yC++) {\n              int xC = wC + yC * "+n+" - "+a+";\n\n              if (xC < 0 || xC >= "+e.inWidth+") {\n                continue;\n              }\n\n              if ("+i+") {\n                float dyValue = getDy(b, yR, yC, d2);\n                float xValue = getX(b, xR, xC, d1);\n                dotProd += (xValue * dyValue);\n              } else {\n                float dyValue = getDy(b, d2, yR, yC);\n                float xValue = getX(b, d1, xR, xC);\n                dotProd += (xValue * dyValue);\n              }\n\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    "},Yj=function(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i="channelsLast"===e.dataFormat,o=t-1-e.padInfo.top,s=n-1-e.padInfo.left,u=i?1:2,l=i?2:3,c=i?3:1;this.userCode="\n      const ivec2 pads = ivec2("+o+", "+s+");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d1 = coords["+c+"];\n\n        ivec2 dyCorner = ivec2(coords["+u+"], coords["+l+"]) - pads;\n        int dyRCorner = dyCorner.x;\n        int dyCCorner = dyCorner.y;\n\n        // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < "+t+"; wR++) {\n          float dyR = float(dyRCorner + wR) / "+r+".0;\n\n          if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          int wRPerm = "+t+" - 1 - wR;\n\n          for (int wC = 0; wC < "+n+"; wC++) {\n            float dyC = float(dyCCorner + wC) / "+a+".0;\n\n            if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            int wCPerm = "+n+" - 1 - wC;\n\n            for (int d2 = 0; d2 < "+e.outChannels+"; d2++) {\n\n              if ("+i+") {\n                float xValue = getDy(batch, idyR, idyC, d2);\n                float wValue = getW(wRPerm, wCPerm, d1, d2);\n                dotProd += xValue * wValue;\n              } else {\n                float xValue = getDy(batch, d2, idyR, idyC);\n                float wValue = getW(wRPerm, wCPerm, d1, d2);\n                dotProd += xValue * wValue;\n              }\n\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    "},Jj=function(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;var t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.padInfo.front,i=e.padInfo.top,o=e.padInfo.left;this.userCode="\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int wF = coords.x;\n        int wR = coords.y;\n        int wC = coords.z;\n        int d1 = coords.w;\n        int d2 = coords.u;\n\n        float dotProd = 0.0;\n\n        for (int b = 0; b < "+e.batchSize+"; b++) {\n          for (int yF = 0; yF < "+e.outDepth+"; yF++) {\n            int xF = wF + yF * "+t+" - "+a+";\n\n            if (xF < 0 || xF >= "+e.inDepth+") {\n              continue;\n            }\n\n            for (int yR = 0; yR < "+e.outHeight+"; yR++) {\n              int xR = wR + yR * "+n+" - "+i+";\n\n              if (xR < 0 || xR >= "+e.inHeight+") {\n                continue;\n              }\n\n              for (int yC = 0; yC < "+e.outWidth+"; yC++) {\n                int xC = wC + yC * "+r+" - "+o+";\n\n                if (xC < 0 || xC >= "+e.inWidth+") {\n                  continue;\n                }\n\n                float dyValue = getDy(b, yF, yR, yC, d2);\n                float xValue = getX(b, xF, xR, xC, d1);\n                dotProd += (xValue * dyValue);\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    "},Zj=function(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;var t=e.filterDepth,n=e.filterHeight,r=e.filterWidth,a=e.strideDepth,i=e.strideHeight,o=e.strideWidth,s=t-1-e.padInfo.front,u=n-1-e.padInfo.top,l=r-1-e.padInfo.left;this.userCode="\n      const ivec3 pads = ivec3("+s+", "+u+", "+l+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d1 = coords.u;\n\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyFCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        float dotProd = 0.0;\n        for (int wF = 0; wF < "+t+"; wF++) {\n          float dyF = float(dyFCorner + wF) / "+a+".0;\n\n          if (dyF < 0.0 || dyF >= "+e.outDepth+".0 || fract(dyF) > 0.0) {\n            continue;\n          }\n          int idyF = int(dyF);\n\n          int wFPerm = "+t+" - 1 - wF;\n\n          for (int wR = 0; wR < "+n+"; wR++) {\n            float dyR = float(dyRCorner + wR) / "+i+".0;\n\n            if (dyR < 0.0 || dyR >= "+e.outHeight+".0 ||\n              fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            int wRPerm = "+n+" - 1 - wR;\n\n            for (int wC = 0; wC < "+r+"; wC++) {\n              float dyC = float(dyCCorner + wC) / "+o+".0;\n\n              if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              int wCPerm = "+r+" - 1 - wC;\n\n              for (int d2 = 0; d2 < "+e.outChannels+"; d2++) {\n                float xValue = getDy(batch, idyF, idyR, idyC, d2);\n                float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n                dotProd += xValue * wValue;\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    "};var Qj={kernelName:"Conv2DBackpropFilter",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.pad,u=r.dataFormat,l=r.dimRoundingMode,c=r.filterShape,p=Yx(u),h=Wx(a.shape,c,o,1,s,l,!1,p),f=new Xj(h);return n.runWebGLProgram(f,[a,i],"float32")}};var $j={kernelName:"Conv2DBackpropInput",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.inputShape,s=r.strides,u=r.pad,l=r.dataFormat,c=r.dimRoundingMode,p=Yx(l),h=Wx(o,i.shape,s,1,u,c,!1,p),f=new Yj(h);return n.runWebGLProgram(f,[a,i],"float32")}};var eH={kernelName:"Conv3D",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dilations,l=Vx(a.shape,i.shape,o,u,s),c=new Gj(l);return n.runWebGLProgram(c,[a,i],"float32")}};var tH={kernelName:"Conv3DBackpropFilterV2",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.pad,u=r.filterShape,l=Vx(a.shape,u,o,1,s),c=new Jj(l);return n.runWebGLProgram(c,[a,i],"float32")}};var nH={kernelName:"Conv3DBackpropInputV2",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.pad,s=r.strides,u=Vx(r.inputShape,i.shape,s,1,o),l=new Zj(u);return n.runWebGLProgram(l,[a,i],"float32")}},rH=hG({opSnippet:"if (isnan(x)) return x;\n  return cos(x);\n"}),aH={kernelName:Qv,backendName:"webgl",kernelFunc:rH},iH={kernelName:"Cosh",backendName:"webgl",kernelFunc:hG({opSnippet:"\n  float e2x = exp(-x);\n  return (e2x + 1.0 / e2x) / 2.0;\n"})},oH=function(e,t,n,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];var i=e[0],o=e[1],s=e[2],u=e[3],l=t[0],c=n[0],p=n[1];this.outputShape=[l,c,p,u];var h="bilinear"===r?1:0,f=o-1+".0",d=s-1+".0",m=c>1?[""+(o-1)/(c-1),"(y2-y1) * height_ratio","y1*"+f+" + float(y)*(height_scale)"]:["0.0","0.0","0.5 * (y1+y2) * "+f],v=m[0],g=m[1],y=m[2],b=p>1?[""+(s-1)/(p-1),"(x2-x1) * width_ratio","x1*"+d+" + float(x)*(width_scale)"]:["0.0","0.0","0.5 * (x1+x2) * "+d],x=b[0],w=b[1],k=b[2];this.userCode="\n      const float height_ratio = float("+v+");\n      const float width_ratio = float("+x+");\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int y = coords[1];\n        int x = coords[2];\n        int d = coords[3];\n\n        // get box vals\n        float y1 = getBoxes(b,0);\n        float x1 = getBoxes(b,1);\n        float y2 = getBoxes(b,2);\n        float x2 = getBoxes(b,3);\n\n        // get image in batch index\n        int bInd = round(getBoxInd(b));\n        if(bInd < 0 || bInd >= "+i+") {\n          return;\n        }\n\n        float height_scale = "+g+";\n        float width_scale = "+w+";\n\n        float in_y = "+y+";\n        if( in_y < 0.0 || in_y > "+f+" ) {\n          setOutput(float("+a+"));\n          return;\n        }\n        float in_x = "+k+";\n        if( in_x < 0.0 || in_x > "+d+" ) {\n          setOutput(float("+a+"));\n          return;\n        }\n\n        vec2 sourceFracIndexCR = vec2(in_x,in_y);\n        if("+h+" == 1) {\n          // Compute the four integer indices.\n          ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n          ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n          float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n          float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n          float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n          float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n          vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n          float top = topLeft + (topRight - topLeft) * fracCR.x;\n          float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n          float newValue = top + (bottom - top) * fracCR.y;\n          setOutput(newValue);\n        } else {\n          // Compute the coordinators of nearest neighbor point.\n          ivec2 sourceNearestCR = ivec2(floor(\n            sourceFracIndexCR + vec2(0.5,0.5)));\n          float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n          setOutput(newValue);\n        }\n      }\n    "},sH={kernelName:"CropAndResize",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.image,i=t.boxes,o=t.boxInd,s=r.cropSize,u=r.method,l=r.extrapolationValue,c=new oH(a.shape,i.shape,s,u,l);return n.runWebGLProgram(c,[a,i,o],"float32")}},uH=function(){function e(e,t,n){this.variableNames=["x"],this.outputShape=e;var r=e.length,a=t?"0.0":"getX("+lH(r,"coords")+")",i=e[e.length-1],o="",s="";t?(o=n?"end != "+(i-1):"end != 0",s=n?"end + 1":"end - 1"):(o=n?"end + pow2 < "+i:"end >= pow2",s=n?"end + pow2":"end - pow2"),this.userCode="\n      uniform float index;\n      void main() {\n        "+iU(r)+" coords = getOutputCoords();\n        int end = "+cH(r,"coords")+";\n        float val = "+a+";\n        int pow2 = int(pow(2.0, index));\n        if ("+o+") {\n          int idx = "+s+";\n          "+cH(r,"coords")+" = idx;\n          val += getX("+lH(r,"coords")+");\n        }\n        setOutput(val);\n      }\n    "}return e.prototype.getCustomSetupFunc=function(e){var t=this;return function(n,r){null==t.index&&(t.index=n.getUniformLocation(r,"index")),n.gl.uniform1f(t.index,e)}},e}();function lH(e,t){if(1===e)return""+t;if(2===e)return t+".x, "+t+".y";if(3===e)return t+".x, "+t+".y, "+t+".z";if(4===e)return t+".x, "+t+".y, "+t+".z, "+t+".w";throw Error("Cumulative sum for rank "+e+" is not yet supported")}function cH(e,t){if(1===e)return""+t;if(2===e)return t+".y";if(3===e)return t+".z";if(4===e)return t+".w";throw Error("Cumulative sum for rank "+e+" is not yet supported")}var pH={kernelName:"Cumsum",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.exclusive,s=r.reverse,u=a.shape.length,l=Ik([i],u),c=a;null!=l&&(c=FG({inputs:{x:a},backend:n,attrs:{perm:l}}));var p=Tk(1,u)[0];if(p!==u-1)throw new Error("WebGL cumsum shader expects an inner-most axis="+(a.shape.length-1)+" but got axis="+i);for(var h=a.shape[p],f=nG({inputs:{x:c},backend:n}),d=0;d<=Math.ceil(Math.log2(h))-1;d++){var m=new uH(c.shape,!1,s),v=m.getCustomSetupFunc(d),g=f;f=n.runWebGLProgram(m,[f],f.dtype,v),n.disposeIntermediateTensorInfo(g)}if(o){var y=new uH(c.shape,o,s),b=f;f=n.runWebGLProgram(y,[f],f.dtype),n.disposeIntermediateTensorInfo(b)}if(null!=l){var x=FG({inputs:{x:f},backend:n,attrs:{perm:Sk(l)}});return n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(c),x}return f}};var hH={kernelName:"DenseBincount",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.weights,o=r.size,s=r.binaryOutput;if(1===a.shape.length){var u=n.texData.get(a.dataId).values,l=n.texData.get(i.dataId).values,c=cU(u,l,i.dtype,i.shape,o);return n.makeTensorInfo([o],i.dtype,c)}if(2===a.shape.length){var p=n.bufferSync(a),h=n.bufferSync(i),f=pU(p,h,o,s);return n.makeTensorInfo(f.shape,i.dtype,f.values)}throw new Error("Error in denseBincount: input must be at most rank 2, but got rank"+a.shape.length+".")}},fH=function(){function e(e,t,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=e,this.blockSize=t,this.dataFormat=n,this.userCode="\n    void main() {\n      ivec4 coords = getOutputCoords();\n      int b = coords[0];\n      int h = "+this.getHeightCoordString()+";\n      int w = "+this.getWidthCoordString()+";\n      int d = "+this.getDepthCoordString()+";\n\n      int in_h = h / "+t+";\n      int offset_h = imod(h, "+t+");\n      int in_w = w / "+t+";\n      int offset_w = imod(w, "+t+");\n      int offset_d = (offset_h * "+t+" + offset_w) *\n        "+this.getOutputDepthSize()+";\n      int in_d = d + offset_d;\n\n      float result = "+this.getInputSamplingString()+";\n      setOutput(result);\n    }\n  "}var t=e.prototype;return t.getHeightCoordString=function(){return"NHWC"===this.dataFormat?"coords[1]":"coords[2]"},t.getWidthCoordString=function(){return"NHWC"===this.dataFormat?"coords[2]":"coords[3]"},t.getDepthCoordString=function(){return"NHWC"===this.dataFormat?"coords[3]":"coords[1]"},t.getOutputDepthSize=function(){return"NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1]},t.getInputSamplingString=function(){return"NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)"},e}();var dH={kernelName:"DepthToSpace",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockSize,o=r.dataFormat;lv(i>1,(function(){return"blockSize should be > 1 for depthToSpace, but was: "+i}));var s=a.shape[0],u="NHWC"===o?a.shape[1]:a.shape[2],l="NHWC"===o?a.shape[2]:a.shape[3],c="NHWC"===o?a.shape[3]:a.shape[1],p=u*i,h=l*i,f=c/(i*i),d=new fH("NHWC"===o?[s,p,h,f]:[s,f,p,h],i,o);return n.runWebGLProgram(d,[a],a.dtype)}},mH=function(e,t,n,r,a){void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x","W"],this.outputShape=e.outShape;var i=e.inHeight,o=e.inWidth,s=e.padInfo.top,u=e.padInfo.left,l=e.strideHeight,c=e.strideWidth,p=e.dilationHeight,h=e.dilationWidth,f=e.filterHeight,d=e.filterWidth,m=e.outChannels/e.inChannels,v="",g="";n&&(v=r?"float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          "+n+"\n        }":a?"float activation(float a) {\n          float b = getLeakyreluAlphaAtOutCoords();\n          "+n+"\n        }":"\n          float activation(float x) {\n            "+n+"\n          }\n        ",g="result = activation(result);");var y=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode="\n      "+v+"\n\n      const ivec2 strides = ivec2("+l+", "+c+");\n      const ivec2 pads = ivec2("+s+", "+u+");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords.x;\n        ivec2 xRCCorner = coords.yz * strides - pads;\n        int d2 = coords.w;\n        int d1 = d2 / "+m+";\n        int q = d2 - d1 * "+m+";\n\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n        for (int wR = 0; wR < "+f+"; wR++) {\n          int xR = xRCorner + wR * "+p+";\n\n          if (xR < 0 || xR >= "+i+") {\n            continue;\n          }\n\n          for (int wC = 0; wC < "+d+"; wC++) {\n            int xC = xCCorner + wC * "+h+";\n\n            if (xC < 0 || xC >= "+o+") {\n              continue;\n            }\n\n            float xVal = getX(batch, xR, xC, d1);\n            float wVal = getW(wR, wC, d1, q);\n            dotProd += xVal * wVal;\n          }\n        }\n\n        float result = dotProd;\n        "+y+"\n        "+g+"\n        setOutput(result);\n      }\n    "},vH=function(e,t,n,r,a){void 0===t&&(t=!1),void 0===n&&(n=null),void 0===r&&(r=!1),void 0===a&&(a=!1),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.outShape;for(var i=e.inHeight,o=e.inWidth,s=e.padInfo.top,u=e.padInfo.left,l=e.strideHeight,c=e.strideWidth,p=e.dilationHeight,h=e.dilationWidth,f=e.filterHeight,d=e.filterWidth,m=d,v="int xR; int xC; int xCOffset;",g=0;g<f;g++)for(var y=0;y<d;y++)v+="\n          vec4 xTexelR"+g+"C"+2*y+" = vec4(0.);\n          vec4 wR"+g+"C"+y+" = vec4(0.);\n          vec4 xR"+g+"C"+y+" = vec4(0.);";for(var b=0;b<f;b++)for(var x=0;x<m;x++){var w=2*x;if(v+="\n          xR = xRCorner + "+b*p+";\n          xC = xCCorner + "+w*h+";\n        ",1===c){if(w<d&&(v+=u%2==1?"\n                xCOffset = xC + 1;\n                if(xR >= 0 && xR < "+i+" && xCOffset >= 0 && xCOffset < "+o+") {\n                  xTexelR"+b+"C"+w+" = getX(batch, xR, xCOffset, d1);\n\n                  // Need to manually clear unused channels in case\n                  // we're reading from recycled texture.\n                  if(xCOffset + 1 >= "+o+") {\n                    xTexelR"+b+"C"+w+".zw = vec2(0.);\n                  }\n                } else {\n                  xTexelR"+b+"C"+w+" = vec4(0.);\n                }\n\n                xCOffset = xC + 1 - 2;\n                if(xR >= 0 && xR < "+i+" && xCOffset >= 0 && xCOffset < "+o+") {\n                  vec4 previous = getX(batch, xR, xCOffset, d1);\n\n                  // Need to manually clear unused channels in case\n                  // we're reading from recycled texture.\n                  if(xCOffset + 1 >= "+o+") {\n                    previous.zw = vec2(0.);\n                  }\n\n                  xR"+b+"C"+w+" = vec4(previous.zw, xTexelR"+b+"C"+w+".xy);\n                } else {\n                  xR"+b+"C"+w+" = vec4(0, 0, xTexelR"+b+"C"+w+".xy);\n                }\n              ":"\n                if(xR >= 0 && xR < "+i+" && xC >= 0 && xC < "+o+") {\n                  xTexelR"+b+"C"+w+" = getX(batch, xR, xC, d1);\n                } else {\n                  xTexelR"+b+"C"+w+" = vec4(0.);\n                }\n\n                xR"+b+"C"+w+" = xTexelR"+b+"C"+w+";\n              ",w+1<d)){var k=u%2==0?sv(h):h;h%2==0&&u%2==1||h%2!=0&&u%2!=1?(v+="\n                  xCOffset = xC + "+u%2+" + "+k+";\n\n                  if(xR >= 0 && xR < "+i+" &&\n                    xCOffset >= 0 && xCOffset < "+o+") {\n                    xTexelR"+b+"C"+(w+2)+" = getX(batch, xR, xCOffset, d1);\n                  }\n                ",h>1&&(v+="\n                    xCOffset -= 2;\n                    if(xR >= 0 && xR < "+i+" &&\n                      xCOffset >= 0 && xCOffset < "+o+") {\n                      xTexelR"+b+"C"+w+" = getX(batch, xR, xCOffset, d1);\n                    } else {\n                      xTexelR"+b+"C"+w+" = vec4(0.);\n                    }\n                  "),v+="\n                  xR"+b+"C"+(w+1)+" = vec4(\n                    xTexelR"+b+"C"+w+".zw, xTexelR"+b+"C"+(w+2)+".xy);\n                "):v+="\n                  xCOffset = xC + "+k+";\n\n                  if(xR >= 0 && xR < "+i+" &&\n                    xCOffset >= 0 && xCOffset < "+o+") {\n                    xTexelR"+b+"C"+(w+2)+" = getX(batch, xR, xCOffset, d1);\n                  }\n\n                  xR"+b+"C"+(w+1)+" = xTexelR"+b+"C"+(w+2)+";\n                "}}else w<d&&(v+="\n              if(xR >= 0 && xR < "+i+") {\n            ",u%2==1?(v+="\n                xCOffset = xC + 1 - "+c+";\n                if(xCOffset >= 0 && xCOffset < "+o+") {\n                  xTexelR"+b+"C"+w+" = getX(batch, xR, xCOffset, d1);\n                } else {\n                  xTexelR"+b+"C"+w+" = vec4(0.);\n                }\n\n                if(xC + 1 >= 0 && xC + 1 < "+o+") {\n                  xTexelR"+b+"C"+(w+2)+" = getX(batch, xR, xC + 1, d1);\n                } else {\n                  xTexelR"+b+"C"+(w+2)+" = vec4(0.);\n                }\n\n                xR"+b+"C"+w+" = vec4(\n                  xTexelR"+b+"C"+w+".zw, xTexelR"+b+"C"+(w+2)+".zw);\n              ",w+1<d&&(v+="\n                  vec4 final = vec4(0.);\n                  xCOffset = xC + 1 + "+c+";\n                  if(xCOffset >= 0 && xCOffset < "+o+") {\n                    final = getX(batch, xR, xCOffset, d1);\n                  }\n                  xR"+b+"C"+(w+1)+" = vec4(xTexelR"+b+"C"+(w+2)+".xy, final.xy);\n                ")):(v+="\n                if(xC >= 0 && xC < "+o+") {\n                  xTexelR"+b+"C"+w+" = getX(batch, xR, xC, d1);\n                } else {\n                  xTexelR"+b+"C"+w+" = vec4(0.);\n                }\n\n                xCOffset = xC + "+c+";\n                if(xCOffset >= 0 && xCOffset < "+o+") {\n                  xTexelR"+b+"C"+(w+2)+" = getX(batch, xR, xCOffset, d1);\n                } else {\n                  xTexelR"+b+"C"+(w+2)+" = vec4(0.);\n                }\n\n                xR"+b+"C"+w+" = vec4(\n                  xTexelR"+b+"C"+w+".xy, xTexelR"+b+"C"+(w+2)+".xy);\n              ",w+1<d&&(v+="\n                  xR"+b+"C"+(w+1)+" = vec4(\n                    xTexelR"+b+"C"+w+".zw, xTexelR"+b+"C"+(w+2)+".zw);\n                ")),v+="}");w<d&&(v+="\n            vec4 wTexelR"+b+"C"+w+" = getW("+b+", "+w+", d1, q);\n            wR"+b+"C"+w+" = vec4(wTexelR"+b+"C"+w+".xz, wTexelR"+b+"C"+w+".xz);\n          ",w+1<d&&(v+="\n              vec4 wTexelR"+b+"C"+(w+1)+" = getW("+b+", "+(w+1)+", d1, q);\n              wR"+b+"C"+(w+1)+" =\n                vec4(wTexelR"+b+"C"+(w+1)+".xz, wTexelR"+b+"C"+(w+1)+".xz);"))}for(var N=0;N<f;N++)for(var I=0;I<d;I++)v+="dotProd += xR"+N+"C"+I+" * wR"+N+"C"+I+";";var S="",T="";n&&(S=r?"vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          "+n+"\n        }":a?"vec4 activation(vec4 a) {\n          vec4 b = getLeakyreluAlphaAtOutCoords();\n          "+n+"\n        }":"vec4 activation(vec4 x) {\n          "+n+"\n        }",T="result = activation(result);");var C=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode="\n      "+S+"\n\n      const ivec2 strides = ivec2("+l+", "+c+");\n      const ivec2 pads = ivec2("+s+", "+u+");\n\n      void main() {\n\n        ivec4 coords = getOutputCoords();\n        int batch = coords.x;\n        ivec2 xRCCorner = coords.yz * strides - pads;\n        int d2 = coords.w;\n        int d1 = d2;\n        int q = 0;\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        vec4 dotProd = vec4(0.);\n\n        "+v+"\n\n        vec4 result = dotProd;\n        "+C+"\n        "+T+"\n        setOutput(result);\n      }\n    "};var gH={kernelName:"DepthwiseConv2dNative",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=r.strides,s=r.pad,u=r.dilations,l=r.dimRoundingMode,c=u;null==c&&(c=[1,1]),lv(Xx(o,c),(function(){return"Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+c+"'"}));var p,h=Wx(a.shape,i.shape,o,c,s,l,!0);return p=Xv().getBool("WEBGL_PACK_DEPTHWISECONV")&&h.strideWidth<=2&&h.outChannels/h.inChannels==1?new vH(h):new mH(h),n.runWebGLProgram(p,[a,i],"float32")}},yH=function(e){this.variableNames=["x","dy"],this.outputShape=e.filterShape;var t=e.strideHeight,n=e.strideWidth,r=e.padInfo.top,a=e.padInfo.left,i=e.outChannels/e.inChannels;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int dm = coords.w;\n        int d2 = d1 * "+i+" + dm;\n\n        float dotProd = 0.0;\n\n        // TO DO: Vec4 over the batch size\n        for (int b = 0; b < "+e.batchSize+"; b++) {\n          for (int yR = 0; yR < "+e.outHeight+"; yR++) {\n            int xR = wR + yR * "+t+" - "+r+";\n\n            if (xR < 0 || xR >= "+e.inHeight+") {\n              continue;\n            }\n\n            for (int yC = 0; yC < "+e.outWidth+"; yC++) {\n              int xC = wC + yC * "+n+" - "+a+";\n\n              if (xC < 0 || xC >= "+e.inWidth+") {\n                continue;\n              }\n\n              float dyValue = getDy(b, yR, yC, d2);\n              float xValue = getX(b, xR, xC, d1);\n              dotProd += (xValue * dyValue);\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    "},bH=function(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;var t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i=t-1-e.padInfo.top,o=n-1-e.padInfo.left,s=e.outChannels/e.inChannels;this.userCode="\n      const ivec2 pads = ivec2("+i+", "+o+");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d1 = coords[3];\n        ivec2 dyCorner = coords.yz - pads;\n        int dyRCorner = dyCorner.x;\n        int dyCCorner = dyCorner.y;\n\n        float dotProd = 0.0;\n\n        for (int wR = 0; wR < "+t+"; wR++) {\n          float dyR = float(dyRCorner + wR) / "+r+".0;\n\n          if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          int wRPerm = "+t+" - 1 - wR;\n\n          for (int wC = 0; wC < "+n+"; wC++) {\n            float dyC = float(dyCCorner + wC) / "+a+".0;\n\n            if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            int wCPerm = "+n+" - 1 - wC;\n\n            // TO DO: Vec4 over the channelMul\n            for (int dm = 0; dm < "+s+"; dm++) {\n              int d2 = d1 * "+s+" + dm;\n              float xValue = getDy(batch, idyR, idyC, d2);\n              float wValue = getW(wRPerm, wCPerm, d1, dm);\n              dotProd += xValue * wValue;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    "};var xH={kernelName:"DepthwiseConv2dNativeBackpropFilter",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.dy,o=r.strides,s=r.dilations,u=r.pad,l=r.dimRoundingMode,c=r.filterShape,p=Wx(a.shape,c,o,s,u,l,!0),h=new yH(p);return n.runWebGLProgram(h,[a,i],"float32")}};var wH={kernelName:"DepthwiseConv2dNativeBackpropInput",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.filter,o=r.strides,s=r.dilations,u=r.pad,l=r.dimRoundingMode,c=Wx(r.inputShape,i.shape,o,s,u,l,!0),p=new bH(c);return n.runWebGLProgram(p,[a,i],"float32")}},kH=function(e){this.variableNames=["X"],this.outputShape=[e,e],this.userCode="\n      void main() {\n          ivec2 coords = getOutputCoords();\n          float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n          setOutput(val);\n      }\n    "};var NH={kernelName:"Diag",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.x,a=[].concat(r.shape,r.shape),i=fv(r.shape),o=kG({inputs:{x:r},backend:n,attrs:{shape:[i]}}),s=new kH(i),u=n.runWebGLProgram(s,[o],o.dtype),l=kG({inputs:{x:u},backend:n,attrs:{shape:a}});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(u),l}},IH=function(e){this.variableNames=["x","W"],this.outputShape=e.outShape;var t=e.inHeight,n=e.inWidth,r=e.padInfo,a=e.strideHeight,i=e.strideWidth,o=e.filterHeight,s=e.filterWidth,u=e.dilationHeight,l=e.dilationWidth,c=r.top,p=r.left;this.userCode="\n      const ivec2 strides = ivec2("+a+", "+i+");\n      const ivec2 pads = ivec2("+c+", "+p+");\n      const float neg_infinity = -3.4e38;\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords.x;\n        int d1 = coords.w;\n        ivec2 outTopLeftCorner =\n            coords.yz * strides - pads;\n        int hBeg = outTopLeftCorner.x;\n        int wBeg = outTopLeftCorner.y;\n\n        float curVal = neg_infinity;\n        for (int h = 0; h < "+o+"; h++) {\n          int hIn = hBeg + h * "+u+";\n\n          if (hIn >= 0 && hIn < "+t+") {\n            for (int w = 0; w < "+s+"; w++) {\n              int wIn = wBeg + w * "+l+";\n\n              if (wIn >= 0 && wIn < "+n+") {\n                float xVal = getX(batch, hIn, wIn, d1);\n                float wVal = getW(h, w, d1);\n\n                float val = xVal + wVal;\n                if (val > curVal) {\n                  curVal = val;\n                }\n              }\n            }\n          }\n        }\n\n        float result = curVal;\n        setOutput(result);\n      }\n    "};var SH={kernelName:"Dilation2D",backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=n.filter,s=a.strides,u=a.pad,l=a.dilations,c=zx(i.shape,o.shape,s,u,"NHWC",l),p=new IH(c),h=kG({inputs:{x:t=r.runWebGLProgram(p,[i,o],"float32")},backend:r,attrs:{shape:c.outShape}});return r.disposeIntermediateTensorInfo(t),h}},TH=hG({opSnippet:"return (x >= 0.0) ? x : (exp(x) - 1.0);",packedOpSnippet:"\n  vec4 result;\n\n  result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n  result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n  result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n  result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n  return result;\n"}),CH={kernelName:$v,backendName:"webgl",kernelFunc:TH},EH={kernelName:"EluGrad",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.dy,a=t.y,i=Xv().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new tG("\n  vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n  return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",r.shape,a.shape):new eG("return (b >= 1.0) ? a : a * (b + 1.0);",r.shape,a.shape);return n.runWebGLProgram(i,[r,a],r.dtype)}},RH={kernelName:"Equal",backendName:"webgl",kernelFunc:fG({opSnippet:"return float(a == b);",packedOpSnippet:"\n  return vec4(equal(a, b));\n",dtype:"bool"})},AH=hG({opSnippet:'\n  // Error function is calculated approximately with elementary function.\n  // See "Handbook of Mathematical Functions with Formulas,\n  // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n  float p = 0.3275911;\n  float a1 = 0.254829592;\n  float a2 = -0.284496736;\n  float a3 = 1.421413741;\n  float a4 = -1.453152027;\n  float a5 = 1.061405429;\n\n  float sign = sign(x);\n  x = abs(x);\n  float t = 1.0 / (1.0 + p * x);\n  return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n'}),DH={kernelName:eg,backendName:"webgl",kernelFunc:AH},FH="return exp(x);",_H=hG({opSnippet:FH,packedOpSnippet:FH,cpuKernelImpl:fU}),OH={kernelName:tg,backendName:"webgl",kernelFunc:_H};function MH(e){var t=e.inputs,n=e.attrs,r=e.backend,a=n.dim,i=t.input,o=i.shape.length,s=i.shape.slice(),u=a;return a<0&&(lv(-(o+1)<=a,(function(){return"Axis must be in the interval ["+-(o+1)+", "+o+"]"})),u=o+a+1),s.splice(u,0,1),kG({inputs:{x:i},backend:r,attrs:{shape:s}})}var LH={kernelName:"ExpandDims",backendName:"webgl",kernelFunc:MH},zH="return exp(x) - 1.0;",PH={kernelName:"Expm1",backendName:"webgl",kernelFunc:hG({opSnippet:zH,packedOpSnippet:zH,cpuKernelImpl:dU})},BH=function(e,t,n){this.variableNames=["real","imag"];var r=t[1];this.outputShape=t;var a,i=n?"2.0 * "+Math.PI:"-2.0 * "+Math.PI,o=n?r+".0":"1.0";if("real"===e)a="return real * expR - imag * expI;";else{if("imag"!==e)throw new Error('FFT component must be either "real" or "imag", got '+e+".");a="return real * expI + imag * expR;"}this.userCode="\n      const float exponentMultiplier = "+i+";\n\n      float unaryOpComplex(float real, float expR, float imag, float expI) {\n        "+a+"\n      }\n\n      float mulMatDFT(int batch, int index) {\n        float indexRatio = float(index) / float("+r+");\n        float exponentMultiplierTimesIndexRatio =\n            exponentMultiplier * indexRatio;\n\n        float result = 0.0;\n\n        for (int i = 0; i < "+r+"; i++) {\n          // x = (-2|2 * PI / N) * index * i;\n          float x = exponentMultiplierTimesIndexRatio * float(i);\n          float expR = cos(x);\n          float expI = sin(x);\n          float real = getReal(batch, i);\n          float imag = getImag(batch, i);\n\n          result +=\n              unaryOpComplex(real, expR, imag, expI) / "+o+";\n        }\n\n        return result;\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        setOutput(mulMatDFT(coords[0], coords[1]));\n      }\n    "};function WH(e,t,n){var r=n.texData.get(e.dataId),a=fv(e.shape),i=e.shape[e.shape.length-1],o=kG({inputs:{x:e},backend:n,attrs:{shape:[a/i,i]}}).shape,s=new BH("real",o,t),u=new BH("imag",o,t),l=[{dataId:r.complexTensorInfos.real.dataId,dtype:r.complexTensorInfos.real.dtype,shape:o},{dataId:r.complexTensorInfos.imag.dataId,dtype:r.complexTensorInfos.imag.dtype,shape:o}],c=n.runWebGLProgram(s,l,"float32"),p=n.runWebGLProgram(u,l,"float32"),h=aG({inputs:{real:c,imag:p},backend:n});n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p);var f=kG({inputs:{x:h},backend:n,attrs:{shape:e.shape}});return n.disposeIntermediateTensorInfo(f),f}var VH={kernelName:"FFT",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend;return WH(t.input,!1,n)}},UH=function(){function e(e,t){this.outputShape=[],this.variableNames=["x"],this.outputShape=e,this.userCode="\n      uniform float value;\n      void main() {\n        // Input can be obtained from uniform value.\n        setOutput(value);\n      }\n    "}return e.prototype.getCustomSetupFunc=function(e){var t=this;return function(n,r){null==t.valueLoc&&(t.valueLoc=n.getUniformLocationNoThrow(r,"value")),n.gl.uniform1f(t.valueLoc,e)}},e}();function GH(e){var t=e.backend,n=e.attrs,r=n.shape,a=n.value,i=n.dtype;if("string"===(i=i||_v(a))){var o=Nv(i,fv(r));return o.fill(a),t.makeTensorInfo(r,i,o)}var s=new UH(r,a),u=s.getCustomSetupFunc(a);return t.runWebGLProgram(s,[],i,u)}var jH,HH={kernelName:"Fill",backendName:"webgl",kernelFunc:GH},qH=function(e){this.variableNames=["Image"],this.outputShape=[];var t=e[2];this.outputShape=e,this.userCode="\n        void main() {\n          ivec4 coords = getOutputCoords();\n          int x = coords[2];\n\n          int coordX = "+t+" - x;\n          float outputValue;\n          if(coordX >= 0 && coordX < "+t+") {\n            outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n          } else {\n            outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n          }\n          setOutput(outputValue);\n        }\n    "},KH={kernelName:"FlipLeftRight",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.image,a=n,i=new qH(r.shape);return a.runWebGLProgram(i,[r],r.dtype)}},XH="return floor(x);",YH={kernelName:"Floor",backendName:"webgl",kernelFunc:hG({opSnippet:XH,packedOpSnippet:XH,cpuKernelImpl:mU})},JH={kernelName:"FloorDiv",backendName:"webgl",kernelFunc:fG({opSnippet:"\n  float s = sign(a) * sign(b);\n  int ia = round(a);\n  int ib = round(b);\n  if (ib != 0) {\n    // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n    return float(idiv(ia, ib, s));\n  } else {\n    return NAN;\n  }\n",packedOpSnippet:"\n  ivec4 ia = round(a);\n  ivec4 ib = round(b);\n  bvec4 cond = notEqual(ib, ivec4(0));\n  ivec4 result = ivec4(0);\n  vec4 s = sign(a) * sign(b);\n\n  // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n  if (cond[0]) {\n    result[0] = idiv(ia[0], ib[0], s[0]);\n  }\n  if (cond[1]) {\n    result[1] = idiv(ia[1], ib[1], s[1]);\n  }\n  if (cond[2]) {\n    result[2] = idiv(ia[2], ib[2], s[2]);\n  }\n  if (cond[3]) {\n    result[3] = idiv(ia[3], ib[3], s[3]);\n  }\n  return vec4(result);\n",dtype:"int32"})},ZH=function(e){this.variableNames=["A"];var t=EV(),n=e[0],r=e[1];this.outputShape=e,this.userCode="\n      void main() {\n        ivec3 coords = getOutputCoords();\n        int texR = coords[0];\n        int texC = coords[1];\n        int depth = coords[2];\n        vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+r+".0, "+n+".0);\n\n        vec4 values = "+t.texture2D+"(A, uv);\n        float value;\n        if (depth == 0) {\n          value = values.r;\n        } else if (depth == 1) {\n          value = values.g;\n        } else if (depth == 2) {\n          value = values.b;\n        } else if (depth == 3) {\n          value = values.a;\n        }\n\n        setOutput(floor(value * 255.0 + 0.5));\n      }\n    "},QH=function(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var t=EV(),n=e[0],r=e[1];this.outputShape=e,this.userCode="\n      void main() {\n        ivec3 coords = getOutputCoords();\n        int texR = coords[0];\n        int texC = coords[1];\n        int depth = coords[2];\n\n        vec4 result = vec4(0.);\n\n        for(int row=0; row<=1; row++) {\n          for(int col=0; col<=1; col++) {\n            texC = coords[1] + row;\n            depth = coords[2] + col;\n\n            vec2 uv = (vec2(texC, texR) + halfCR) /\n                       vec2("+r+".0, "+n+".0);\n            vec4 values = "+t.texture2D+"(A, uv);\n            float value;\n            if (depth == 0) {\n              value = values.r;\n            } else if (depth == 1) {\n              value = values.g;\n            } else if (depth == 2) {\n              value = values.b;\n            } else if (depth == 3) {\n              value = values.a;\n            }\n\n            result[row * 2 + col] = floor(value * 255.0 + 0.5);\n          }\n        }\n\n        "+t.output+" = result;\n      }\n    "},$H={kernelName:"FromPixels",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.pixels,i=r.numChannels,o="undefined"!=typeof HTMLVideoElement&&a instanceof HTMLVideoElement,s="undefined"!=typeof HTMLImageElement&&a instanceof HTMLImageElement,u=o?[a.videoWidth,a.videoHeight]:[a.width,a.height],l=u[0],c=u[1],p=[c,l],h=[c,l,i];(s||o)&&(null==jH&&(jH=document.createElement("canvas").getContext("2d")),jH.canvas.width=l,jH.canvas.height=c,jH.drawImage(a,0,0,l,c),a=jH.canvas);var f=n.makeTensorInfo(p,"int32");n.texData.get(f.dataId).usage=KW.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(f.dataId),a);var d=Xv().getBool("WEBGL_PACK")?new QH(h):new ZH(h),m=n.runWebGLProgram(d,[f],"int32");return n.disposeData(f.dataId),m}};var eq={kernelName:"FusedConv2D",backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=n.filter,s=n.bias,u=n.preluActivationWeights,l=a.strides,c=a.pad,p=a.dataFormat,h=a.dilations,f=a.dimRoundingMode,d=a.activation,m=a.leakyreluAlpha,v=Yx(p),g=Wx(i.shape,o.shape,l,h,c,f,!1,v),y=[];if(1!==g.filterHeight||1!==g.filterWidth||1!==g.dilationHeight||1!==g.dilationWidth||1!==g.strideHeight||1!==g.strideWidth||"SAME"!==g.padInfo.type&&"VALID"!==g.padInfo.type)if(Xv().getBool("WEBGL_CONV_IM2COL")&&1===i.shape[0])t=qj({x:i,filter:o,convInfo:g,backend:r,bias:s,activation:d,preluActivationWeights:u,leakyreluAlpha:m});else{var b=null!=s,x=null!=u,w="leakyrelu"===d,k=d?dG(d,!1):null,N=new Uj(g,b,k,x,w),I=[i,o];if(s&&I.push(s),u&&I.push(u),w){var S=r.makeTensorInfo([],"float32",vg(m,"float32"));I.push(S),y.push(S)}t=r.runWebGLProgram(N,I,"float32")}else t=Hj({x:i,filter:o,convInfo:g,backend:r,bias:s,activation:d,preluActivationWeights:u,leakyreluAlpha:m});var T=kG({inputs:{x:t},backend:r,attrs:{shape:g.outShape}});return y.push(t),y.forEach((function(e){return r.disposeIntermediateTensorInfo(e)})),T}};var tq={kernelName:"FusedDepthwiseConv2D",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.filter,o=t.bias,s=t.preluActivationWeights,u=r.strides,l=r.pad,c=r.dilations,p=r.dimRoundingMode,h=r.activation,f=r.leakyreluAlpha,d=[],m=c;null==m&&(m=[1,1]),lv(Xx(u,m),(function(){return"Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides "+u+" and dilations '"+m+"'"}));var v,g=Wx(a.shape,i.shape,u,m,l,p,!0),y=Xv().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,b=h?dG(h,y):null,x=[a,i],w=null!=o,k=null!=s,N="leakyrelu"===h;if(w&&x.push(o),k&&x.push(s),N){var I=n.makeTensorInfo([],"float32",vg(f,"float32"));x.push(I),d.push(I)}v=y?new vH(g,w,b,k,N):new mH(g,w,b,k,N);var S=n.runWebGLProgram(v,x,"float32");return d.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),S}},nq=function(e,t,n){this.sliceDim=e,this.strides=t,this.variableNames=["x","indices"],this.outputShape=n;var r=iU(t.length),a=iU(n.length),i=this.sliceDim>1?"strides[j]":"strides";this.userCode="\n        "+r+" strides = "+r+"("+this.strides+");\n         void main() {\n          "+a+" coords = getOutputCoords();\n          int flattenIndex = 0;\n          for (int j = 0; j < "+this.sliceDim+"; j++) {\n            int index = round(getIndices(coords[0], j));\n            flattenIndex += index * "+i+";\n          }\n          setOutput(getX(flattenIndex, coords[1]));\n        }\n      "};var rq={kernelName:"GatherNd",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.params,a=t.indices,i=a.shape,o=i[i.length-1],s=_b(r,a),u=s[0],l=s[1],c=s[2],p=s[3],h=kG({inputs:{x:a},backend:n,attrs:{shape:[l,o]}}),f=kG({inputs:{x:r},backend:n,attrs:{shape:[fv(r.shape)/c,c]}}),d=new nq(o,p,[l,c]),m=n.runWebGLProgram(d,[f,h],f.dtype),v=kG({inputs:{x:m},backend:n,attrs:{shape:u}});return n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),v}},aq=function(e,t){this.variableNames=["A","indices"],this.outputShape=t,this.rank=t.length;var n=iU(this.rank),r=function(e,t){for(var n=["resRC.x","resRC.y","resRC.z","resRC.w"],r=[],a=0;a<e.length;a++)2===a?r.push("int(getIndices(resRC.x, resRC.z))"):r.push(""+n[a]);return r.join()}(e);this.userCode="\n      void main() {\n        "+n+" resRC = getOutputCoords();\n        setOutput(getA("+r+"));\n      }\n    "};var iq={kernelName:"GatherV2",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.indices,o=r.axis,s=r.batchDims,u=TT(a,i,xv(o,a.shape)[0],s),l=fv(i.shape),c=[],p=kG({inputs:{x:a},backend:n,attrs:{shape:[u.batchSize,u.outerSize,u.dimSize,u.sliceSize]}}),h=kG({inputs:{x:i},backend:n,attrs:{shape:[u.batchSize,l/u.batchSize]}});c.push(p),c.push(h);var f=[u.batchSize,u.outerSize,l/u.batchSize,u.sliceSize];if(n.shouldExecuteOnCPU([a,i])||"string"===a.dtype){var d=n.bufferSync(h),m=n.bufferSync(p),v=vU(m,d,f);return c.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),n.makeTensorInfo(u.outputShape,v.dtype,v.values)}var g=new aq(p.shape,f),y=n.runWebGLProgram(g,[p,h],p.dtype);c.push(y);var b=kG({inputs:{x:y},backend:n,attrs:{shape:u.outputShape}});return c.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),b}},oq={kernelName:"Greater",backendName:"webgl",kernelFunc:fG({opSnippet:"return float(a > b);",packedOpSnippet:"\n  return vec4(greaterThan(a, b));\n",cpuKernelImpl:gU,dtype:"bool"})},sq={kernelName:"GreaterEqual",backendName:"webgl",kernelFunc:fG({opSnippet:"return float(a >= b);",packedOpSnippet:"\n  return vec4(greaterThanEqual(a, b));\n",dtype:"bool"})};var uq={kernelName:"IFFT",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend;return WH(t.input,!0,n)}},lq={kernelName:"IsFinite",backendName:"webgl",kernelFunc:hG({opSnippet:"return float(!isnan(x) && !isinf(x));",dtype:"bool"})},cq={kernelName:"IsInf",backendName:"webgl",kernelFunc:hG({opSnippet:"return float(isinf(x));",dtype:"bool"})},pq={kernelName:"IsNan",backendName:"webgl",kernelFunc:hG({opSnippet:"return float(isnan(x));",dtype:"bool"})},hq={kernelName:"Less",backendName:"webgl",kernelFunc:fG({opSnippet:"return float(a < b);",packedOpSnippet:"\n  return vec4(lessThan(a, b));\n",cpuKernelImpl:yU,dtype:"bool"})},fq={kernelName:"LessEqual",backendName:"webgl",kernelFunc:fG({opSnippet:"return float(a <= b);",packedOpSnippet:"\n  return vec4(lessThanEqual(a, b));\n",dtype:"bool"})};var dq={kernelName:"LinSpace",backendName:"webgl",kernelFunc:function(e){var t=e.backend,n=e.attrs,r=n.start,a=n.stop,i=n.num,o=bU(r,a,i);return t.makeTensorInfo([o.length],"float32",o)}},mq=hG({opSnippet:"if (x < 0.0) return NAN;\n  return log(x);",packedOpSnippet:"\n  vec4 result = log(x);\n  vec4 isNaN = vec4(lessThan(x, vec4(0.0)));\n  result.r = isNaN.r == 1.0 ? NAN : result.r;\n  result.g = isNaN.g == 1.0 ? NAN : result.g;\n  result.b = isNaN.b == 1.0 ? NAN : result.b;\n  result.a = isNaN.a == 1.0 ? NAN : result.a;\n\n  return result;\n",cpuKernelImpl:xU}),vq={kernelName:ng,backendName:"webgl",kernelFunc:mq},gq={kernelName:"Log1p",backendName:"webgl",kernelFunc:hG({opSnippet:"return log(1.0 + x);"})},yq={kernelName:"LogicalAnd",backendName:"webgl",kernelFunc:fG({opSnippet:"return float(a >= 1.0 && b >= 1.0);",packedOpSnippet:"\n  return vec4(\n    vec4(greaterThanEqual(a, vec4(1.0))) *\n    vec4(greaterThanEqual(b, vec4(1.0))));\n",dtype:"bool"})},bq={kernelName:"LogicalNot",backendName:"webgl",kernelFunc:hG({opSnippet:"return float(!(x >= 1.0));"})},xq={kernelName:"LogicalOr",backendName:"webgl",kernelFunc:fG({opSnippet:"return float(a >= 1.0 || b >= 1.0);",packedOpSnippet:"\n  return min(\n    vec4(greaterThanEqual(a, vec4(1.0))) +\n    vec4(greaterThanEqual(b, vec4(1.0))),\n    vec4(1.0));\n",dtype:"bool"})},wq=function(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[];var i,o=t,s=e[3]-1;this.outputShape=e;var u="float("+n+") + float("+r+") * sum";i=.5===a?"inversesqrt("+u+")":1===a?"1.0/("+u+")":"exp(log("+u+") * float(-"+a+"));",this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int r = coords[1];\n        int c = coords[2];\n        int d = coords[3];\n        float x = getX(b, r, c, d);\n        float sum = 0.0;\n        for (int j = -"+o+"; j <= "+o+"; j++) {\n          int idx = d + j;\n          if (idx >= 0 && idx <=  "+s+") {\n            float z = getX(b, r, c, idx);\n            sum += z * z;\n          }\n        }\n        float val = x * "+i+";\n        setOutput(val);\n      }\n    "},kq=function(e,t,n,r,a){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var i,o=t,s=e[3]-1;this.outputShape=e;var u="float("+n+") + float("+r+") * sum";i=.5===a?"inversesqrt("+u+")":1===a?"1.0/("+u+")":"exp(log("+u+") * float(-"+a+"));",this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords.x;\n        int r = coords.y;\n        int c = coords.z;\n        int d = coords.w;\n\n        bool hasNextCol = d < "+this.outputShape[3]+";\n        bool hasNextRow = c < "+this.outputShape[2]+";\n\n        vec4 sum = vec4(0.);\n        vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n        vec4 xAtOutputCoords = vec4(\n          getChannel(xFragAtOutputCoords, vec2(c, d)),\n          hasNextCol ?\n            getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n          hasNextRow ?\n            getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n        );\n\n        int firstChannel = d - "+o+";\n        vec2 cache = vec2(0.);\n        if(firstChannel >= 0){\n          vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n          cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n            if(hasNextRow){\n              cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n            }\n        }\n\n        ivec2 depth = ivec2(d, d + 1);\n        for (int j = - "+o+"; j <= "+o+"; j++) {\n          ivec2 idx = depth + j;\n          bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n          bvec2 belowUpperBound = lessThanEqual(idx, ivec2("+s+"));\n\n          bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n          bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n          if(depthInRange || depthPlusOneInRange){\n            vec4 z = vec4(0.);\n            vec4 xFragAtCurrentDepth;\n            z.xz = cache.xy;\n            if(depthPlusOneInRange && hasNextCol){\n              xFragAtCurrentDepth = idx.y != d ?\n                getX(b, r, c, idx.y) : xFragAtOutputCoords;\n              z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n              if(hasNextRow){\n                z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n              }\n            }\n            cache.xy = z.yw;\n            sum += z * z;\n          }\n        }\n        vec4 result = xAtOutputCoords * "+i+";\n        setOutput(result);\n      }\n    "},Nq={kernelName:"LRN",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.depthRadius,o=r.bias,s=r.alpha,u=r.beta,l=Xv().getBool("WEBGL_PACK_NORMALIZATION")?new kq(a.shape,i,o,s,u):new wq(a.shape,i,o,s,u);return n.runWebGLProgram(l,[a],a.dtype)}},Iq=function(e,t,n,r,a){this.variableNames=["inputImage","outputImage","dy"],this.outputShape=[],this.outputShape=e,this.depth=e[3],this.depthRadius=t,this.bias=n,this.alpha=r,this.beta=a,this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int r = coords[1];\n        int c = coords[2];\n\n        float result = 0.0;\n        for (int d = 0; d < "+this.depth+"; ++d) {\n          int depthBegin = int(max(0.0, float(d - "+t+")));\n          int depthEnd = int(min(float("+this.depth+"),\n              float(d + "+t+" + 1)));\n\n          const int MIN_DEPTH_BEGIN = 0;\n          const int MAX_DEPTH_END = "+this.depth+";\n\n          float norm = 0.0;\n          for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n            if (k < depthBegin){\n              continue;\n            }\n            else if (k >= depthBegin && k < depthEnd) {\n              norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n            }\n            else {\n              break;\n            }\n          }\n\n          norm = float("+r+") * norm + float("+n+");\n\n          for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n            if (k < depthBegin){\n              continue;\n            }\n            else if (k >= depthBegin && k < depthEnd){\n              float dyi = -2.0 * float("+r+")\n                * float("+a+")\n                * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n                / norm;\n              if (k == d) {\n                dyi += pow(norm, -1.0 * "+a+");\n              }\n              if (k == coords[3]) {\n                dyi *= getDy(b, r, c, d);\n                result += dyi;\n              }\n            }\n            else {\n              break;\n            }\n          }\n      }\n      setOutput(result);\n      }\n    "},Sq={kernelName:"LRNGrad",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.y,o=t.dy,s=r.depthRadius,u=r.bias,l=r.alpha,c=r.beta,p=new Iq(a.shape,s,u,l,c);return n.runWebGLProgram(p,[a,i,o],a.dtype)}};function Tq(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.reductionIndices,o=r.keepDims,s=a.shape.length,u=xv(i,a.shape),l=u,c=Ik(l,s),p=null!=c,h=n.shouldExecuteOnCPU([a]),f=a;if(p){if(h){for(var d=n.texData.get(f.dataId).values,m=new Array(s),v=0;v<m.length;v++)m[v]=a.shape[c[v]];var g=MU(d,a.shape,a.dtype,c,m);f=n.makeTensorInfo(m,a.dtype),n.texData.get(f.dataId).values=g}else f=RG(a,c,n);l=Tk(l.length,s)}Nk("max",l,s);var y,b=wk(f.shape,l),x=b[0],w=b[1],k=x;if(o&&(k=kk(x,u)),h){var N=n.texData.get(f.dataId).values,I=wU(N,fv(w),k,a.dtype);y=n.makeTensorInfo(k,a.dtype),n.texData.get(y.dataId).values=I}else y=function(e,t,n,r){var a=fv(t),i=kG({inputs:{x:e},attrs:{shape:[fv(e.shape)/a,a]},backend:r}),o=TG(i,e.dtype,"max",r),s=kG({inputs:{x:o},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),s}(f,w,k,n);return p&&n.disposeIntermediateTensorInfo(f),y}var Cq={kernelName:"Max",backendName:"webgl",kernelFunc:Tq},Eq={kernelName:"Maximum",backendName:"webgl",kernelFunc:fG({opSnippet:"\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return max(a, b);\n",packedOpSnippet:"\n  vec4 result = vec4(max(a, b));\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n",cpuKernelImpl:kU})};var Rq={kernelName:"MaxPool",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x;TV(a,"maxPool");var i=r.filterSize,o=r.strides,s=r.pad,u=r.dimRoundingMode;lv(Xx(o,1),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+o+" and dilations '1'"}));var l=Px(a.shape,i,o,1,s,u);if(1===l.filterWidth&&1===l.filterHeight&&dv(l.inShape,l.outShape))return nG({inputs:{x:a},backend:n});var c=new rj(l,"max",!1);return n.runWebGLProgram(c,[a],a.dtype)}};var Aq={kernelName:"MaxPool3D",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.filterSize,o=r.strides,s=r.pad,u=r.dataFormat,l=r.dimRoundingMode,c=Bx(a.shape,i,o,[1,1,1],s,l,u),p=new aj(c,"max",!1);return n.runWebGLProgram(p,[a],a.dtype)}},Dq=function(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;var t=e.strideHeight,n=e.strideWidth,r=e.dilationHeight,a=e.effectiveFilterHeight,i=e.effectiveFilterWidth,o=a-1-e.padInfo.top,s=i-1-e.padInfo.left,u=a*i-1;this.userCode="\n      const ivec2 pads = ivec2("+o+", "+s+");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n\n        ivec2 dyRCCorner = coords.yz - pads;\n        int dyRCorner = dyRCCorner.x;\n        int dyCCorner = dyRCCorner.y;\n\n        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < "+a+";\n          wR += "+r+") {\n          float dyR = float(dyRCorner + wR) / "+t+".0;\n\n          if (dyR < 0.0 || dyR >= "+e.outHeight+".0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          for (int wC = 0; wC < "+i+"; wC++) {\n            float dyC = float(dyCCorner + wC) / "+n+".0;\n\n            if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            float dyValue = getDy(b, idyR, idyC, d);\n            int maxPosValue = "+u+" - int(getMaxPos(b, idyR, idyC, d));\n\n            // Get the current value, check it against the value from the\n            // position matrix.\n            int curPosValue = wR * "+i+" + wC;\n            float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n            dotProd += dyValue * mask;\n          }\n        }\n        setOutput(dotProd);\n      }\n    "},Fq=function(e){this.variableNames=["dy","maxPos"],this.outputShape=e.inShape;var t=e.strideDepth,n=e.strideHeight,r=e.strideWidth,a=e.dilationDepth,i=e.dilationHeight,o=e.dilationWidth,s=e.effectiveFilterDepth,u=e.effectiveFilterHeight,l=e.effectiveFilterWidth,c=s-1-e.padInfo.front,p=u-1-e.padInfo.top,h=l-1-e.padInfo.left,f=s*u*l-1;this.userCode="\n      const ivec3 pads = ivec3("+c+", "+p+", "+h+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n        // dx(xD, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < "+s+";\n           wD += "+a+") {\n          float dyD = float(dyDCorner + wD) / "+t+".0;\n\n          if (dyD < 0.0 || dyD >= "+e.outDepth+".0 || fract(dyD) > 0.0) {\n            continue;\n          }\n          int idyD = int(dyD);\n\n          for (int wR = 0; wR < "+u+";\n              wR += "+i+") {\n            float dyR = float(dyRCorner + wR) / "+n+".0;\n\n            if (dyR < 0.0 || dyR >= "+e.outHeight+".0 ||\n                fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            for (int wC = 0; wC < "+l+";\n                wC += "+o+") {\n              float dyC = float(dyCCorner + wC) / "+r+".0;\n\n              if (dyC < 0.0 || dyC >= "+e.outWidth+".0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n              int maxPosValue = "+f+" -\n                  int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n              // Get the current value, check it against the value from the\n              // position matrix.\n              int curPosValue =\n                  wD * "+u+" * "+l+" +\n                  wR * "+l+" + wC;\n              float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n              dotProd += dyValue * mask;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    "};var _q={kernelName:"MaxPool3DGrad",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=r.filterSize,s=r.strides,u=r.pad,l=r.dimRoundingMode,c=Bx(i.shape,o,s,[1,1,1],u,l),p=new aj(c,"max",!0),h=n.runWebGLProgram(p,[i],i.dtype),f=new Fq(c),d=n.runWebGLProgram(f,[a,h],i.dtype);return n.disposeIntermediateTensorInfo(h),d}};var Oq={kernelName:"MaxPoolGrad",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.dy,i=t.input,o=i;TV([i,t.output],"maxPoolGrad");var s=r.filterSize,u=r.strides,l=r.pad,c=r.dimRoundingMode,p=Px(o.shape,s,u,1,l,c),h=new rj(p,"max",!0),f=n.runWebGLProgram(h,[o],o.dtype),d=new Dq(p),m=n.runWebGLProgram(d,[a,f],o.dtype);return n.disposeIntermediateTensorInfo(f),m}};var Mq={kernelName:"MaxPoolWithArgmax",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,i=n.filterSize,o=n.strides,s=n.pad,u=n.includeBatchInIndex,l=r;lv(4===a.shape.length,(function(){return"Error in maxPool: input must be rank 4 but got rank "+a.shape.length+"."}));var c=[1,1];lv(Xx(o,c),(function(){return"Error in maxPool: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+c+"'"}));var p=Px(a.shape,i,o,c,s),h=function(e,t,n,r){var a=new rj(n,"max",!1),i=r.runWebGLProgram(a,[e],"float32");return a=new rj(n,"max",!0,!0,t),[i,r.runWebGLProgram(a,[e],"float32")]}(a,u,p,l);return[h[0],h[1]]}};var Lq={kernelName:"Mean",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,i=n.keepDims,o=n.axis,s=r,u=a.shape.length,l=xv(o,a.shape),c=l,p=Ik(c,u),h=null!=p,f=s.shouldExecuteOnCPU([a]),d=[],m=a;if(h){if(f){for(var v=s.texData.get(m.dataId).values,g=new Array(u),y=0;y<g.length;y++)g[y]=a.shape[p[y]];var b=MU(v,a.shape,a.dtype,p,g);m=s.makeTensorInfo(g,a.dtype),s.texData.get(m.dataId).values=b}else m=RG(a,p,s);d.push(m),c=Tk(c.length,u)}Nk("sum",c,u);var x=wk(m.shape,c),w=x[0],k=x[1],N=w;i&&(N=kk(w,l));for(var I=function(e,t,n,r){var a=fv(t),i=kG({inputs:{x:e},attrs:{shape:[fv(e.shape)/a,a]},backend:r}),o=TG(i,"float32","mean",r),s=kG({inputs:{x:o},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),s}(m,k,N,s),S=0,T=d;S<T.length;S++){var C=T[S];s.disposeIntermediateTensorInfo(C)}return I}};var zq={kernelName:"Min",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.axis,o=r.keepDims,s=a.shape.length,u=xv(i,a.shape),l=u,c=Ik(l,s),p=a;null!=c&&(p=FG({inputs:{x:a},backend:n,attrs:{perm:c}}),l=Tk(l.length,a.shape.length)),Nk("min",l,s);var h,f=wk(p.shape,l),d=f[0],m=kG({inputs:{x:p},backend:n,attrs:{shape:[-1,fv(f[1])]}}),v=TG(m,m.dtype,"min",n);return h=kG(o?{inputs:{x:v},backend:n,attrs:{shape:kk(d,u)}}:{inputs:{x:v},backend:n,attrs:{shape:d}}),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(v),null!=c&&n.disposeIntermediateTensorInfo(p),h}},Pq={kernelName:"Minimum",backendName:"webgl",kernelFunc:fG({opSnippet:"\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return min(a, b);\n",packedOpSnippet:"\n  vec4 result = vec4(min(a, b));\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n",cpuKernelImpl:NU})},Bq=function(e,t,n){this.variableNames=["x"],this.outputShape=t.map((function(t,n){return t[0]+e[n]+t[1]}));var r=e.length,a=iU(r),i=t.map((function(e){return e[0]})).join(","),o=t.map((function(t,n){return t[0]+e[n]})).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r),u="reflect"===n?0:1;this.userCode=1!==r?"\n      "+a+" start = "+a+"("+i+");\n      "+a+" end = "+a+"("+o+");\n\n      void main() {\n        "+a+" outC = getOutputCoords();\n        for (int i = 0; i < "+r+"; i++) {\n          if (outC[i] < start[i]) {\n            outC[i] = start[i] * 2 - outC[i] - "+u+";\n          } else if(outC[i] >= end[i]) {\n            outC[i] = (end[i] - 1) * 2 - outC[i] + "+u+";\n          }\n        }\n        "+a+" coords = outC - start;\n        setOutput(getX("+s+"));\n      }\n    ":"\n        int start = "+i+";\n        int end = "+o+";\n\n        void main() {\n          int outC = getOutputCoords();\n          if (outC < start) {\n            outC = start * 2 - outC - "+u+";\n          } else if(outC >= end) {\n            outC = (end - 1) * 2 - outC + "+u+";\n          }\n          setOutput(getX(outC - start));\n        }\n      "},Wq=function(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((function(t,n){return t[0]+e[n]+t[1]}));var r=e.length,a=iU(r),i=t.map((function(e){return e[0]})).join(","),o=t.map((function(t,n){return t[0]+e[n]})).join(","),s=PU("rc",r),u=PU("source",r),l=s[r-1]+" < "+this.outputShape[r-1],c=1===r?"source":"vec2("+u.slice(-2).join()+")",p="reflect"===n?0:1,h="";if(1===r){var f="\n        "+a+" source = rc;\n        if (source < start) {\n          source = start * 2 - source - "+p+";\n        } else if (source >= end) {\n          source = (end - 1) * 2 - source + "+p+";\n        }\n        source -= start;\n      ";h="\n        "+a+" rc = outputLoc;\n        "+f+"\n        result[0] = getChannel(getX("+u.join()+"), "+c+");\n        "+s[r-1]+" += 1;\n        if("+l+") {\n          "+f+"\n          result[1] = getChannel(getX("+u.join()+"), "+c+");\n        }\n      "}else{var d="\n        "+a+" source = rc;\n        "+a+" lt = "+a+"(lessThan(source, start));\n        "+a+" gte = "+a+"(greaterThanEqual(source, end));\n        "+a+" orig = 1 - (lt + gte);\n        source = orig * source +\n                lt * (start * 2 - source - "+p+") +\n                gte * ((end - 1) * 2 - source + "+p+");\n        source -= start;\n      ";h="\n        "+a+" rc = outputLoc;\n        "+d+"\n        result[0] = getChannel(getX("+u.join()+"), "+c+");\n        "+s[r-1]+" += 1;\n        if("+l+") {\n          "+d+"\n          result[1] = getChannel(getX("+u.join()+"), "+c+");\n        }\n        rc = outputLoc;\n        "+s[r-2]+" += 1;\n        if("+s[r-2]+" < "+this.outputShape[r-2]+") {\n          "+d+"\n          result[2] = getChannel(getX("+u.join()+"), "+c+");\n          "+s[r-1]+" += 1;\n          if("+l+") {\n            "+d+"\n            result[3] = getChannel(getX("+u.join()+"), "+c+");\n          }\n        }\n      "}this.userCode="\n      const "+a+" start = "+a+"("+i+");\n      const "+a+" end = "+a+"("+o+");\n\n      void main() {\n        "+a+" outputLoc = getOutputCoords();\n        vec4 result = vec4(0.);\n        "+h+"\n        setOutput(result);\n      }\n    "},Vq={kernelName:"MirrorPad",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.paddings,o=r.mode,s=Xv().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Wq(a.shape,i,o):new Bq(a.shape,i,o);return n.runWebGLProgram(s,[a],a.dtype)}},Uq=fG({opSnippet:"if (b == 0.0) return NAN;\n  return mod(a, b);",packedOpSnippet:"\n  vec4 result = mod(a, b);\n  vec4 isNaN = vec4(equal(b, vec4(0.0)));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n"}),Gq={kernelName:rg,backendName:"webgl",kernelFunc:Uq},jq=function(){function e(e,t,n){this.variableNames=["probs"],this.outputShape=[e,n],this.userCode="\n      uniform float seed;\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n\n        float r = random(seed);\n        float cdf = 0.0;\n\n        for (int i = 0; i < "+(t-1)+"; i++) {\n          cdf += getProbs(batch, i);\n\n          if (r < cdf) {\n            setOutput(float(i));\n            return;\n          }\n        }\n\n        // If no other event happened, last event happened.\n        setOutput(float("+(t-1)+"));\n      }\n    "}return e.prototype.getCustomSetupFunc=function(e){var t=this;return function(n,r){null==t.seedLoc&&(t.seedLoc=n.getUniformLocation(r,"seed")),n.gl.uniform1f(t.seedLoc,e)}},e}(),Hq=fG({opSnippet:"\nif (a == b) {\n  return 1.0;\n};\nreturn a / b;",packedOpSnippet:"\n  // vec4 one = vec4(equal(a, b));\n  // return one + (vec4(1.0) - one) * a / b;\n  vec4 result = a / b;\n  if(a.x == b.x) {\n    result.x = 1.;\n  }\n  if(a.y == b.y) {\n    result.y = 1.;\n  }\n  if(a.z == b.z) {\n    result.z = 1.;\n  }\n  if(a.w == b.w) {\n    result.w = 1.;\n  }\n\n  return result;\n",checkOutOfBounds:!0}),qq={kernelName:"RealDiv",backendName:"webgl",kernelFunc:Hq},Kq="return a - b;",Xq=fG({opSnippet:Kq,packedOpSnippet:Kq,supportsComplex:!0,cpuKernelImpl:FU}),Yq={kernelName:og,backendName:"webgl",kernelFunc:Xq};function Jq(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.logits,i=xv([r.dim],a.shape),o=Tq({inputs:{x:a},backend:n,attrs:{reductionIndices:i,keepDims:!1}}),s=kk(o.shape,i),u=kG({inputs:{x:o},backend:n,attrs:{shape:s}}),l=Xq({inputs:{a:a,b:u},backend:n}),c=_H({inputs:{x:l},backend:n}),p=AG({inputs:{x:c},backend:n,attrs:{axis:i,keepDims:!1}}),h=kG({inputs:{x:p},backend:n,attrs:{shape:s}}),f=Hq({inputs:{a:c,b:h},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(h),f}var Zq={kernelName:"Softmax",backendName:"webgl",kernelFunc:Jq};var Qq={kernelName:"Multinomial",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.logits,i=r.numSamples,o=r.seed,s=r.normalized,u=s?a:Jq({inputs:{logits:a},backend:n,attrs:{dim:a.shape.length-1}}),l=u.shape[0],c=u.shape[1],p=new jq(l,c,i),h=p.getCustomSetupFunc(o),f=n.runWebGLProgram(p,[u],"int32",h);return s||n.disposeIntermediateTensorInfo(u),f}},$q="return -x;";var eK={kernelName:"Neg",backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=n.x;if(r.shouldExecuteOnCPU([a])){var i=r.texData.get(a.dataId),o=SU(i.values,a.shape,a.dtype),s=o[0],u=o[1];return r.makeTensorInfo(u,a.dtype,s)}return t=Xv().getBool("WEBGL_PACK_UNARY_OPERATIONS")?new YU(a.shape,$q):new HU(a.shape,$q),r.runWebGLProgram(t,[a],a.dtype)}},tK=cS;var nK={kernelName:"NonMaxSuppressionV3",backendName:"webgl",kernelFunc:function(e){dT("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,l=n.readSync(a.dataId),c=n.readSync(i.dataId),p=tK(l,c,o,s,u).selectedIndices;return n.makeTensorInfo([p.length],"int32",new Int32Array(p))}},rK=pS;var aK={kernelName:"NonMaxSuppressionV4",backendName:"webgl",kernelFunc:function(e){dT("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,l=r.padToMaxOutputSize,c=n.readSync(a.dataId),p=n.readSync(i.dataId),h=rK(c,p,o,s,u,l),f=h.selectedIndices,d=h.validOutputs;return[n.makeTensorInfo([f.length],"int32",new Int32Array(f)),n.makeTensorInfo([],"int32",new Int32Array([d]))]}},iK=hS;var oK={kernelName:"NonMaxSuppressionV5",backendName:"webgl",kernelFunc:function(e){dT("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var t=e.inputs,n=e.backend,r=e.attrs,a=t.boxes,i=t.scores,o=r.maxOutputSize,s=r.iouThreshold,u=r.scoreThreshold,l=r.softNmsSigma,c=n.readSync(a.dataId),p=n.readSync(i.dataId),h=iK(c,p,o,s,u,l),f=h.selectedIndices,d=h.selectedScores;return[n.makeTensorInfo([f.length],"int32",new Int32Array(f)),n.makeTensorInfo([d.length],"float32",new Float32Array(d))]}},sK=function(e,t,n,r){this.variableNames=["indices"],this.outputShape=[e,t],this.userCode="\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int index = round(getIndices(coords.x));\n        setOutput(mix(float("+r+"), float("+n+"),\n                      float(index == coords.y)));\n      }\n    "},uK={kernelName:"OneHot",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.indices,i=r.depth,o=r.onValue,s=r.offValue,u=fv(a.shape),l=new sK(u,i,o,s),c=kG({inputs:{x:a},backend:n,attrs:{shape:[u]}}),p=n.runWebGLProgram(l,[c],a.dtype);n.disposeIntermediateTensorInfo(c);var h=kG({inputs:{x:p},backend:n,attrs:{shape:[].concat(a.shape,[i])}});return n.disposeIntermediateTensorInfo(p),h}};function lK(e){var t=e.inputs,n=e.backend,r=t.x;if("complex64"===r.dtype){var a=Ij({inputs:{input:r},backend:n}),i=lK({inputs:{x:a},backend:n}),o=Pj({inputs:{input:r},backend:n}),s=lK({inputs:{x:o},backend:n}),u=aG({inputs:{real:i,imag:s},backend:n});return n.disposeIntermediateTensorInfo(a),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(s),u}return GH({attrs:{shape:r.shape,dtype:r.dtype,value:"string"===r.dtype?"":0},backend:n})}var cK={kernelName:"ZerosLike",backendName:"webgl",kernelFunc:lK};var pK={kernelName:"OnesLike",backendName:"webgl",kernelFunc:function e(t){var n=t.inputs,r=t.backend,a=n.x;if("string"===a.dtype)throw new Error("onesLike is not supported under string dtype");if("complex64"===a.dtype){var i=Ij({inputs:{input:a},backend:r}),o=e({inputs:{x:i},backend:r}),s=Pj({inputs:{input:a},backend:r}),u=lK({inputs:{x:s},backend:r}),l=aG({inputs:{real:o,imag:u},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(o),r.disposeIntermediateTensorInfo(s),r.disposeIntermediateTensorInfo(u),l}return GH({attrs:{shape:a.shape,dtype:a.dtype,value:1},backend:r})}};var hK={kernelName:"Pack",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs.axis;if(1===t.length)return MH({inputs:{input:t[0]},backend:n,attrs:{dim:r}});var a=t[0].shape,i=t[0].dtype;t.forEach((function(e){cv(a,e.shape,"All tensors passed to stack must have matching shapes"),lv(i===e.dtype,(function(){return"All tensors passed to stack must have matching dtypes"}))}));var o=[],s=Wj({inputs:t.map((function(e){var t=MH({inputs:{input:e},backend:n,attrs:{dim:r}});return o.push(t),t})),backend:n,attrs:{axis:r}});return o.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),s}},fK=function(e,t,n){this.variableNames=["x"],this.outputShape=t.map((function(t,n){return t[0]+e[n]+t[1]}));var r=e.length,a=iU(r),i=t.map((function(e){return e[0]})).join(","),o=t.map((function(t,n){return t[0]+e[n]})).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?"\n      "+a+" start = "+a+"("+i+");\n      "+a+" end = "+a+"("+o+");\n\n      void main() {\n        "+a+" outC = getOutputCoords();\n        if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n          setOutput(float("+n+"));\n        } else {\n          "+a+" coords = outC - start;\n          setOutput(getX("+s+"));\n        }\n      }\n    ":"\n        int start = "+i+";\n        int end = "+o+";\n\n        void main() {\n          int outC = getOutputCoords();\n          if (outC < start || outC >= end) {\n            setOutput(float("+n+"));\n          } else {\n            setOutput(getX(outC - start));\n          }\n        }\n      "},dK=function(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.map((function(t,n){return t[0]+e[n]+t[1]}));for(var r=e.length,a=iU(r),i=t.map((function(e){return e[0]})).join(","),o=t.map((function(t,n){return t[0]+e[n]})).join(","),s=PU("rc",r),u=PU("source",r),l=s[r-1]+" < "+this.outputShape[r-1],c=1===r?"source":"vec2("+u.slice(-2).join()+")",p=[a+" rc = outputLoc;",s[r-1]+" += 1;\n       if("+l+") {\n      ",1===r?"":"}\n       rc = outputLoc;\n       "+s[r-2]+" += 1;\n       if("+s[r-2]+" < "+this.outputShape[r-2]+") {",1===r?"":"  "+s[r-1]+" += 1;\n         if("+l+") {"],h=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",f="",d=0,m=1===r?2:4;d<m;d++)f+="\n        "+p[d]+"\n        if ("+h+") {\n          result["+d+"] = float("+n+");\n        } else {\n          "+a+" source = rc - start;\n          result["+d+"] = getChannel(getX("+u.join()+"), "+c+");\n        }\n      ";f+=1===r?"} ":"}}",this.userCode="\n      const "+a+" start = "+a+"("+i+");\n      const "+a+" end = "+a+"("+o+");\n\n      void main() {\n        "+a+" outputLoc = getOutputCoords();\n        vec4 result = vec4(0.);\n        "+f+"\n        setOutput(result);\n      }\n    "},mK=function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.paddings,o=r.constantValue,s=Xv().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new dK(a.shape,i,o):new fK(a.shape,i,o);return n.runWebGLProgram(s,[a],a.dtype)},vK={kernelName:"PadV2",backendName:"webgl",kernelFunc:mK},gK=fG({opSnippet:"\n  if(a < 0.0 && floor(b) < b){\n    return NAN;\n  }\n  if (b == 0.0) {\n    return 1.0;\n  }\n  return (round(mod(b, 2.0)) != 1) ?\n      pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",packedOpSnippet:"\n  // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n  vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n  vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n  vec4 result = multiplier * pow(abs(a), b);\n\n  // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n  bvec4 isExpZero = equal(b, vec4(0.0));\n  result.r = isExpZero.r ? 1.0 : result.r;\n  result.g = isExpZero.g ? 1.0 : result.g;\n  result.b = isExpZero.b ? 1.0 : result.b;\n  result.a = isExpZero.a ? 1.0 : result.a;\n\n  vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n"}),yK={kernelName:ag,backendName:"webgl",kernelFunc:gK};var bK={kernelName:"Prod",backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=a.axis,s=a.keepDims,u=i.shape.length,l=[],c=xv(o,i.shape),p=c,h=Ik(p,u),f=i;if(null!=h&&(f=FG({inputs:{x:i},backend:r,attrs:{perm:h}}),p=Tk(p.length,u),l.push(f)),Nk("prod",p,u),r.shouldExecuteOnCPU([f])){var d=r.texData.get(f.dataId).values,m=TU(f.shape,f.dtype,d,p),v=m.outVals,g=m.outShape,y=m.outDtype;t=r.makeTensorInfo(g,y,v)}else{var b=wk(f.shape,p),x=b[0],w=fv(b[1]),k=kG({inputs:{x:f},backend:r,attrs:{shape:[-1,w]}}),N=TG(k,Vg(i.dtype),"prod",r);t=kG({inputs:{x:N},backend:r,attrs:{shape:x}}),l.push(k),l.push(N)}if(s){l.push(t);var I=kk(t.shape,c);t=kG({inputs:{x:t},backend:r,attrs:{shape:I}})}return l.forEach((function(e){return r.disposeIntermediateTensorInfo(e)})),t}},xK=function(e){var t=e.backend,n=e.attrs,r=n.start,a=n.stop,i=n.step,o=n.dtype,s=CU(r,a,i,o);return t.makeTensorInfo([s.length],o,s)},wK={kernelName:"Range",backendName:"webgl",kernelFunc:xK},kK={kernelName:"Reciprocal",backendName:"webgl",kernelFunc:hG({opSnippet:"return 1.0 / x;"})},NK={kernelName:"Relu",backendName:"webgl",kernelFunc:hG({opSnippet:"if (isnan(x)) return x;\n  return (x < 0.0) ? 0.0 : x;\n",packedOpSnippet:"\n  vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n  bvec4 isNaN = isnan(x);\n\n  result.r = isNaN.r ? x.r : result.r;\n  result.g = isNaN.g ? x.g : result.g;\n  result.b = isNaN.b ? x.b : result.b;\n  result.a = isNaN.a ? x.a : result.a;\n\n  return result;\n"})},IK={kernelName:"Relu6",backendName:"webgl",kernelFunc:hG({opSnippet:"if (isnan(x)) return x;\n  return (x < 0.0) ? 0.0 : min(6.0, x);\n",packedOpSnippet:"\n  vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n  bvec4 isNaN = isnan(x);\n\n  result.r = isNaN.r ? x.r : result.r;\n  result.g = isNaN.g ? x.g : result.g;\n  result.b = isNaN.b ? x.b : result.b;\n  result.a = isNaN.a ? x.a : result.a;\n\n  return result;\n"})},SK=function(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];var i=e[0],o=e[1],s=e[2],u=e[3];this.outputShape=[i,t,n,u];var l,c=[r&&t>1?o-1:o,r&&n>1?s-1:s],p=[r&&t>1?t-1:t,r&&n>1?n-1:n];l=a?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode="\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          "+c[0]/p[0]+",\n          "+c[1]/p[1]+");\n      const vec2 inputShapeRC = vec2("+o+".0, "+s+".0);\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        ivec2 yRC = coords.yz;\n\n        // Fractional source index.\n        vec2 sourceFracIndexRC = "+l+";\n\n        // Compute the four integer indices.\n        ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\n        ivec2 sourceCeilRC = ivec2(\n          min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n        float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n        float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n        float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n        float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n        vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n        float top = topLeft + (topRight - topLeft) * fracRC.y;\n        float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n        float newValue = top + (bottom - top) * fracRC.x;\n\n        setOutput(newValue);\n      }\n    "},TK=function(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var i=e[0],o=e[1],s=e[2],u=e[3];this.outputShape=[i,t,n,u];var l,c=[r&&t>1?o-1:o,r&&n>1?s-1:s],p=[r&&t>1?t-1:t,r&&n>1?n-1:n];l=a?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode="\n      const vec3 effectiveInputOverOutputRatioRC = vec3(\n          "+c[0]/p[0]+",\n          "+c[1]/p[1]+",\n          "+c[1]/p[1]+");\n      const vec3 inputShapeRC = vec3("+o+".0, "+s+".0,\n                                     "+s+".0);\n\n      float getAValue(int b, int r, int c, int d) {\n        return getChannel(getA(b, r, c, d), vec2(c, d));\n      }\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        // Calculate values for next column in yRC.z.\n        ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n        // Fractional source index.\n        vec3 sourceFracIndexRC = "+l+";\n\n        // Compute the four integer indices.\n        ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\n        ivec3 sourceCeilRC = ivec3(\n          min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n        // Should we calculate next column and row elements in 2x2 packed cell.\n        bool hasNextCol = d < "+(u-1)+";\n        bool hasNextRow = coords.z < "+(n-1)+";\n\n        // In parallel, construct four corners for all four components in\n        // packed 2x2 cell.\n        vec4 topLeft = vec4(\n          getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n        vec4 bottomLeft = vec4(\n          getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n        vec4 topRight = vec4(\n          getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n        vec4 bottomRight = vec4(\n          getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n        vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n        vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n        vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n        vec4 newValue = mix(top, bottom, fracRC.x);\n\n        setOutput(newValue);\n      }\n    "};var CK={kernelName:"ResizeBilinear",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=r.alignCorners,o=r.halfPixelCenters,s=r.size,u=s[0],l=s[1],c=Xv().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new TK(a.shape,u,l,i,o):new SK(a.shape,u,l,i,o);return n.runWebGLProgram(c,[a],"float32")}},EK=function(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;var r=t[1],a=t[2],i=e[1],o=e[2],s=[n&&i>1?r-1:r,n&&o>1?a-1:a],u=[n&&i>1?i-1:i,n&&o>1?o-1:o],l=s[0]/u[0],c=s[1]/u[1],p=1/l,h=1/c,f=2*Math.ceil(p)+2,d=2*Math.ceil(h)+2;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float("+l+");\n        const float widthScale = float("+c+");\n\n        const float invHeightScale = float("+p+");\n        const float invWidthScale = float("+h+");\n\n        const int winHeight = int("+f+");\n        const int winWidth = int("+d+");\n\n        // Compute bounds for where in dy we will look\n        float startRLerp = floor(float(r) * invHeightScale);\n        int startDyR = int(startRLerp - float(winHeight / 2));\n\n        float startCLerp = floor(float(c) * invWidthScale);\n        int startDyC = int(startCLerp - float(winWidth / 2));\n\n        // Loop over dy\n        for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n          int dyR = dyROffset + startDyR;\n\n          // Guard against the window exceeding the bounds of dy\n          if (dyR < 0 || dyR >= "+i+") {\n            continue;\n          }\n\n          for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n            int dyC = dyCOffset + startDyC;\n\n            // Guard against the window exceeding the bounds of dy\n            if (dyC < 0 || dyC >= "+o+") {\n              continue;\n            }\n\n            float dxR = float(dyR) * heightScale;\n            int topDxRIndex = int(floor(dxR));\n            int bottomDxRIndex = int(min(ceil(dxR), "+(r-1)+".0));\n            float dxRLerp = dxR - float(topDxRIndex);\n            float inverseDxRLerp = 1.0 - dxRLerp;\n\n            float dxC = float(dyC) * widthScale;\n            int leftDxCIndex = int(floor(dxC));\n            int rightDxCIndex = int(min(ceil(dxC), "+(a-1)+".0));\n            float dxCLerp = dxC - float(leftDxCIndex);\n            float inverseDxCLerp = 1.0 - dxCLerp;\n\n            if (r == topDxRIndex && c == leftDxCIndex) {\n              // topLeft\n              accumulator +=\n                getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n            }\n\n            if (r == topDxRIndex && c == rightDxCIndex) {\n              // topRight\n              accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n            }\n\n            if (r == bottomDxRIndex && c == leftDxCIndex) {\n              // bottomLeft\n              accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n            }\n\n            if (r == bottomDxRIndex && c == rightDxCIndex) {\n              // bottomRight\n              accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n            }\n          }\n        }\n        // End loop over dy\n\n        setOutput(accumulator);\n      }\n    "};var RK={kernelName:"ResizeBilinearGrad",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=t.dy,o=r.alignCorners,s=new EK(i.shape,a.shape,o);return n.runWebGLProgram(s,[i],i.dtype)}},AK=function(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];var i=e[0],o=e[1],s=e[2],u=e[3];this.outputShape=[i,t,n,u];var l,c=[r&&t>1?o-1:o,r&&n>1?s-1:s],p=[r&&t>1?t-1:t,r&&n>1?n-1:n],h=r?"0.5":"0.0";l=a?"max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode="\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          "+c[0]/p[0]+",\n          "+c[1]/p[1]+");\n      const vec2 inputShapeRC = vec2("+o+".0, "+s+".0);\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        ivec2 yRC = coords.yz;\n\n        // Fractional source index.\n        vec2 sourceFracIndexRC = "+l+";\n\n        // Compute the coordinators of nearest neighbor point.\n        ivec2 sourceNearestRC = ivec2(\n          min(inputShapeRC - 1.0, floor(sourceFracIndexRC + "+h+")));\n        float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n        setOutput(newValue);\n      }\n    "};var DK={kernelName:"ResizeNearestNeighbor",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=r.alignCorners,o=r.halfPixelCenters,s=r.size,u=s[0],l=s[1],c=new AK(a.shape,u,l,i,o);return n.runWebGLProgram(c,[a],a.dtype)}},FK=function(e,t,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=t;var r=t[1],a=t[2],i=e[1],o=e[2],s=[n&&i>1?r-1:r,n&&o>1?a-1:a],u=[n&&i>1?i-1:i,n&&o>1?o-1:o],l=s[0]/u[0],c=s[1]/u[1],p=1/l,h=1/c,f=2*Math.ceil(p)+2,d=2*Math.ceil(h)+2;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float("+l+");\n        const float widthScale = float("+c+");\n\n        const float invHeightScale = float("+p+");\n        const float invWidthScale = float("+h+");\n\n        const int winHeight = int("+f+");\n        const int winWidth = int("+d+");\n\n        // Compute bounds for where in dy we will look\n        float startRLerp = floor(float(r) * invHeightScale);\n        int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n        float startCLerp = floor(float(c) * invWidthScale);\n        int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n        // Loop over dy\n        for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n          int dyR = dyROffset + startDyR;\n\n          // Guard against the window exceeding the bounds of dy\n          if (dyR < 0 || dyR >= "+i+") {\n            continue;\n          }\n\n          for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n            int dyC = dyCOffset + startDyC;\n\n            // Guard against the window exceeding the bounds of dy\n            if (dyC < 0 || dyC >= "+o+") {\n              continue;\n            }\n\n            float sourceFracRow =\n              float("+s[0]+") *\n                (float(dyR) / float("+u[0]+"));\n\n            float sourceFracCol =\n                float("+s[1]+") *\n                  (float(dyC) / float("+u[1]+"));\n\n            int sourceNearestRow = int(min(\n                float(int("+r+") - 1),\n                "+n+" ? float(round(sourceFracRow)) :\n                                  float(floor(sourceFracRow))));\n\n            int sourceNearestCol = int(min(\n                float(int("+a+") - 1),\n                "+n+" ? float(round(sourceFracCol)) :\n                                  float(floor(sourceFracCol))));\n\n            if (r == sourceNearestRow && c == sourceNearestCol) {\n              accumulator += getDy(b, dyR, dyC, d);\n            }\n          }\n        }\n        // End loop over dy\n\n        setOutput(accumulator);\n      }\n    "};var _K={kernelName:"ResizeNearestNeighborGrad",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.images,i=t.dy,o=r.alignCorners,s=new FK(i.shape,a.shape,o);return n.runWebGLProgram(s,[i],i.dtype)}},OK=function(e,t){this.variableNames=["x"];var n=e.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");if(this.outputShape=e,1!==n){var r=e.map((function(n,r){return function(n){return-1!==t.indexOf(n)&&1!==e[n]?e[n]+" - coords["+n+"] - 1":"coords["+n+"]"}(r)})).join(","),a=iU(n);this.userCode="\n      void main() {\n        "+a+" coords = getOutputCoords();\n        setOutput(getX("+r+"));\n      }\n    "}else this.userCode="\n        void main() {\n          int coord = getOutputCoords();\n          setOutput(getX("+e[0]+" - coord - 1));\n        }\n      "},MK=function(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;var n=e.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");this.outputShape=e;var r=PU("rc",n),a=r[n-1]+" + 1 < "+this.outputShape[n-1],i=r[n-2]+" + 1 < "+this.outputShape[n-2],o=iU(n);function s(n){var r=e.map((function(r,a){return function(n,r){return-1!==t.indexOf(n)&&1!==e[n]?e[n]+" - "+r[n]+" - 1":""+r[n]}(a,n)}));return"getChannel(getX("+r.join(",")+"), vec2("+r.slice(-2).join(",")+"))"}this.userCode=1===n?"\n        void main(){\n          int rc = getOutputCoords();\n          vec4 result = vec4(0.);\n          result.r = getChannel(getX("+e[0]+" - rc - 1),\n            "+e[0]+" - rc - 1);\n          if("+a+"){\n              result.g = getChannel(getX("+e[0]+" - (rc  + 1) - 1),\n                "+e[0]+" - (rc  + 1) - 1);\n          }\n          setOutput(result);\n        }\n      ":"\n        void main() {\n          "+o+" rc = getOutputCoords();\n          vec4 result = vec4(0.);\n          result.r = "+function(e){return s(e)}(r.slice())+";\n          if("+a+"){\n            result.g = "+function(e){return e[n-1]="("+e[n-1]+" + 1)",s(e)}(r.slice())+";\n          }\n          if("+i+") {\n            result.b = "+function(e){return e[n-2]="("+e[n-2]+" + 1)",s(e)}(r.slice())+";\n            if("+a+") {\n              result.a = "+function(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",s(e)}(r.slice())+";\n            }\n          }\n          setOutput(result);\n        }\n    "};var LK={kernelName:"Reverse",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.dims,o=a.shape.length,s=xv(i,a.shape);if(0===o)return nG({inputs:{x:a},backend:n});var u=Xv().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new MK(a.shape,s):new OK(a.shape,s);return n.runWebGLProgram(u,[a],a.dtype)}},zK=function(e,t,n,r){this.variableNames=["Image"],this.outputShape=[];var a=e[1],i=e[2],o=Math.sin(t).toFixed(3),s=Math.cos(t).toFixed(3);this.outputShape=e;var u=sT(r,a,i),l=u[0],c=u[1],p=l.toFixed(3),h=c.toFixed(3),f="";f="number"==typeof n?"float outputValue = "+n.toFixed(2)+";":"\n        vec3 fill = vec3("+n.join(",")+");\n        float outputValue = fill[coords[3]];",this.userCode="\n        void main() {\n          ivec4 coords = getOutputCoords();\n          int x = coords[2];\n          int y = coords[1];\n          float coordXFloat = (float(x) - "+p+") * "+s+" - (float(y) - "+h+") * "+o+";\n          float coordYFloat = (float(x) - "+p+") * "+o+" + (float(y) - "+h+") * "+s+";\n          int coordX = int(round(coordXFloat + "+p+"));\n          int coordY = int(round(coordYFloat + "+h+"));\n          "+f+"\n          if(coordX >= 0 && coordX < "+i+" && coordY >= 0 && coordY < "+a+") {\n            outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n          }\n          setOutput(outputValue);\n        }\n    "},PK={kernelName:"RotateWithOffset",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.image,i=n.radians,o=n.fillValue,s=n.center,u=r,l=new zK(a.shape,i,o,s);return u.runWebGLProgram(l,[a],a.dtype)}},BK={kernelName:"Round",backendName:"webgl",kernelFunc:hG({opSnippet:"\n  // OpenGL ES does not support round function.\n  // The algorithm is based on banker's rounding.\n  float base = floor(x);\n  if ((x - base) < 0.5) {\n    return floor(x);\n  } else if ((x - base) > 0.5) {\n    return ceil(x);\n  } else {\n    if (mod(base, 2.0) == 0.0) {\n      return base;\n    } else {\n      return base + 1.0;\n    }\n  }\n"})},WK={kernelName:"Rsqrt",backendName:"webgl",kernelFunc:hG({opSnippet:"return inversesqrt(x);",cpuKernelImpl:EU})},VK=function(e,t,n,r,a,i,o){void 0===o&&(o=!0),this.variableNames=["updates","indices","defaultValue"],this.outputShape=i;var s=iU(a.length),u=iU(i.length),l="";1===n?l="i":2===n&&(l="i, j");var c="getIndices("+l+")",p="";1===r?p="i":2===r&&(p="i, coords[1]");var h="getUpdates("+p+")",f=t>1?"strides[j]":"strides";this.userCode="\n        "+s+" strides = "+s+"("+a+");\n\n        void main() {\n          "+u+" coords = getOutputCoords();\n          float sum = 0.0;\n          bool found = false;\n          for (int i = 0; i < "+e+"; i++) {\n            int flattenedIndex = 0;\n            for (int j = 0; j < "+t+"; j++) {\n              int index = round("+c+");\n              flattenedIndex += index * "+f+";\n            }\n            if (flattenedIndex == coords[0]) {\n              sum += "+h+";\n              found = true;\n            }\n          }\n          setOutput(mix(getDefaultValue(), sum, float(found)));\n        }\n      "};var UK={kernelName:"ScatterNd",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.indices,i=t.updates,o=r.shape,s=zb(0,a,o),u=s.sliceRank,l=s.numUpdates,c=s.sliceSize,p=s.strides,h=s.outputSize,f=[h/c,c];if(0===h)return n.makeTensorInfo(o,a.dtype);var d=kG({inputs:{x:a},backend:n,attrs:{shape:[l,u]}}),m=kG({inputs:{x:i},backend:n,attrs:{shape:[l,c]}}),v=n.makeTensorInfo([],"float32",new Float32Array([0])),g=new VK(l,u,d.shape.length,m.shape.length,p,f),y=n.runWebGLProgram(g,[m,d,v],m.dtype),b=kG({inputs:{x:y},backend:n,attrs:{shape:o}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(m),n.disposeIntermediateTensorInfo(y),n.disposeIntermediateTensorInfo(v),b}},GK=function(e,t,n){var r,a;if(this.variableNames=["c","a","b"],this.outputShape=t,n>4)throw Error("Where for rank "+n+" is not yet supported");if(1===n)a="resRC",r="resRC";else{for(var i=["resRC.x","resRC.y","resRC.z","resRC.w"],o=[],s=[],u=0;u<t.length;u++)s.push(""+i[u]),u<e&&o.push(""+i[u]);r=o.join(),a=s.join()}var l=iU(n);this.userCode="\n      void main() {\n        "+l+" resRC = getOutputCoords();\n        float cVal = getC("+r+");\n        if (cVal >= 1.0) {\n          setOutput(getA("+a+"));\n        } else {\n          setOutput(getB("+a+"));\n        }\n      }\n    "};var jK={kernelName:"Select",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=t.condition,a=t.t,i=t.e,o=new GK(r.shape.length,a.shape,a.shape.length);return n.runWebGLProgram(o,[r,a,i],Wg(a.dtype,i.dtype))}},HK={kernelName:"Selu",backendName:"webgl",kernelFunc:hG({opSnippet:"\n  // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n  // see: https://arxiv.org/abs/1706.02515\n  float scaleAlpha = 1.7580993408473768;\n  float scale = 1.0507009873554805;\n  return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n"})},qK={kernelName:"Sigmoid",backendName:"webgl",kernelFunc:hG({opSnippet:"return 1.0 / (1.0 + exp(-1.0 * x));"})},KK={kernelName:"Sign",backendName:"webgl",kernelFunc:hG({opSnippet:"\n  if (isnan(x)) { return 0.0; }\n  return sign(x);\n"})},XK=hG({opSnippet:"if (isnan(x)) return x;\n  return sin(x);\n"}),YK={kernelName:ig,backendName:"webgl",kernelFunc:XK},JK={kernelName:"Sinh",backendName:"webgl",kernelFunc:hG({opSnippet:"\n  float e2x = exp(x);\n  return (e2x - 1.0 / e2x) / 2.0;\n"})},ZK={kernelName:"Softplus",backendName:"webgl",kernelFunc:hG({opSnippet:"\n  float epsilon = 1.1920928955078125e-7;\n  float threshold = log(epsilon) + 2.0;\n\n  bool too_large = x > -threshold;\n  bool too_small = x < threshold;\n\n  float result;\n  float exp_x = exp(x);\n\n  if (too_large){\n    result = x;\n  }\n  else if (too_small){\n    result = exp_x;\n  }\n  else{\n    result = log(exp_x + 1.0);\n  }\n  return result;\n"})},QK={kernelName:"SpaceToBatchND",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.blockShape,o=r.paddings;lv(a.shape.length<=4,(function(){return"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"}));var s=i.reduce((function(e,t){return e*t})),u=[[0,0]];u.push.apply(u,o);for(var l=1+i.length;l<a.shape.length;++l)u.push([0,0]);var c=[],p=mK({inputs:{x:a},backend:n,attrs:{paddings:u,constantValue:0}}),h=uT(p.shape,i,s,!1),f=lT(h.length,i.length,!1),d=cT(p.shape,i,s,!1),m=kG({inputs:{x:p},backend:n,attrs:{shape:h}}),v=FG({inputs:{x:m},backend:n,attrs:{perm:f}}),g=kG({inputs:{x:v},backend:n,attrs:{shape:d}});return c.push(p),c.push(m),c.push(v),c.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),g}};var $K={kernelName:"SparseToDense",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.sparseIndices,i=t.sparseValues,o=t.defaultValue,s=r.outputShape,u=zb(0,a,s),l=u.sliceRank,c=u.numUpdates,p=u.strides,h=u.outputSize,f=new VK(c,l,a.shape.length,i.shape.length,p,[h,1],!1),d=n.runWebGLProgram(f,[i,a,o],i.dtype),m=kG({inputs:{x:d},backend:n,attrs:{shape:s}});return n.disposeIntermediateTensorInfo(d),m}};var eX={kernelName:"SplitV",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.numOrSizeSplits,o=r.axis,s=xv(o,a.shape)[0],u=NT(a,i,s),l=a.shape.length,c=new Array(l).fill(0),p=a.shape.slice();return u.map((function(e){var t=[].concat(p);t[o]=e;var r=yj({inputs:{x:a},backend:n,attrs:{begin:c,size:t}});return c[o]+=e,r}))}},tX={kernelName:"Sqrt",backendName:"webgl",kernelFunc:hG({opSnippet:"return sqrt(x);"})},nX={kernelName:"Square",backendName:"webgl",kernelFunc:hG({opSnippet:"return x * x;"})},rX={kernelName:"SquaredDifference",backendName:"webgl",kernelFunc:fG({opSnippet:"return (a - b) * (a - b);",packedOpSnippet:"return (a - b) * (a - b);"})};var aX={kernelName:"Step",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=t.x,i=qU+"\n    return x > 0.0 ? 1.0 : float("+n.alpha+");\n  ",o=new HU(a.shape,i);return r.runWebGLProgram(o,[a],a.dtype)}},iX=function(e,t,n){this.variableNames=["x"],this.outputShape=n;var r=n.length,a=iU(n.length),i=iU(n.length),o="";if(1===r)o="coords * strides + begin";else{var s=0;o=n.map((function(e,t){return s++,1===n.length?"coords * strides["+t+"] + begin["+t+"]":"coords["+(s-1)+"] * strides["+t+"] + begin["+t+"]"})).join(",")}this.userCode="\n      "+a+" begin = "+a+"("+e+");\n      "+a+" strides = "+a+"("+t+");\n\n      void main() {\n        "+i+" coords = getOutputCoords();\n        setOutput(getX("+o+"));\n      }\n    "};var oX={kernelName:"StridedSlice",backendName:"webgl",kernelFunc:function(e){var t,n=e.inputs,r=e.backend,a=e.attrs,i=n.x,o=a.begin,s=a.end,u=a.strides,l=a.beginMask,c=a.endMask,p=a.ellipsisMask,h=a.newAxisMask,f=a.shrinkAxisMask,d=ex(i.shape,o,s,u,l,c,p,h,f),m=d.nonStrided,v=d.$begin,g=d.$strides,y=d.size,b=d.newShape,x=d.outShape,w=kG({inputs:{x:i},backend:r,attrs:{shape:b}});if(m){var k=yj({inputs:{x:w},backend:r,attrs:{begin:v,size:y}});t=kG({inputs:{x:k},backend:r,attrs:{shape:x}}),r.disposeIntermediateTensorInfo(k)}else if(x.some((function(e){return 0===e})))t=r.makeTensorInfo(x,i.dtype,[]);else{if(r.shouldExecuteOnCPU([w])){var N=r.texData.get(w.dataId).values,I=nb(w.shape,w.dtype,N),S=DU(x,I,g,v);t=r.makeTensorInfo(x,w.dtype,S.values)}else{var T=new iX(v,g,x);t=r.runWebGLProgram(T,[w],w.dtype)}}var C=kG({inputs:{x:t},backend:r,attrs:{shape:x}});return r.disposeIntermediateTensorInfo(w),r.disposeIntermediateTensorInfo(t),C}},sX=hG({opSnippet:"return tan(x);"}),uX={kernelName:sg,backendName:"webgl",kernelFunc:sX},lX=hG({opSnippet:"\n  float e2x = exp(-2.0 * abs(x));\n  return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n"}),cX=function(e,t){this.variableNames=["A"];for(var n=new Array(e.length),r=0;r<n.length;r++)n[r]=e[r]*t[r];this.outputShape=n,this.rank=n.length;var a=iU(this.rank),i=function(e){var t=e.length;if(t>5)throw Error("Tile for rank "+t+" is not yet supported");if(1===t)return"imod(resRC, "+e[0]+")";for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[],a=0;a<e.length;a++)r.push("imod("+n[a]+", "+e[a]+")");return r.join()}(e);this.userCode="\n      void main() {\n        "+a+" resRC = getOutputCoords();\n        setOutput(getA("+i+"));\n      }\n    "};function pX(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.reps;if("string"===a.dtype){var o=n.texData.get(a.dataId).values.map((function(e){return wg(e)})),s=nb(a.shape,a.dtype,o),u=_U(s,i);return n.makeTensorInfo(u.shape,u.dtype,u.values)}var l=new cX(a.shape,i);return n.runWebGLProgram(l,[a],a.dtype)}var hX=function(e,t){this.variableNames=["x","segmentIds"];var n=e.windowSize,r=e.batchSize,a=e.inSize,i=e.numSegments,o=i*Math.ceil(a/n);this.outputShape=[r,o];var s=4*Math.floor(n/4),u=n%4,l="\n        sumValue += dot(values, segFilter);\n    ",c="";a%n>0&&(c="\n        if (inIdx < 0 || inIdx >= "+a+") {\n          return initializationValue;\n        }\n      ");var p="";a%n>0&&(p="\n        if (inIdx < 0 || inIdx >= "+a+") {\n          return -1.0;\n        }\n      "),this.userCode="\n      const float initializationValue = 0.0;\n\n      float getValue(int batch, int inIdx) {\n        "+c+"\n        return getX(batch, inIdx);\n      }\n\n      float getSegmentIdAtIndex(int inIdx) {\n        "+p+"\n        return getSegmentIds(inIdx);\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = int(floor(float(outIdx) / float(\n          "+i+")) * float("+n+"));\n        int currentSeg = int(mod(float(outIdx), float("+i+")));\n\n        float sumValue = 0.0;\n\n        for (int i = 0; i < "+s+"; i += 4) {\n          int inIdx = inOffset + i;\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            getValue(batch, inIdx + 3)\n          );\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n          );\n\n          "+l+"\n        }\n\n        int inIdx = inOffset + "+s+";\n        if ("+(1===u)+") {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            initializationValue,\n            initializationValue,\n            initializationValue\n          );\n\n          int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            0,\n            0,\n            0\n          );\n\n          "+l+"\n        } else if ("+(2===u)+") {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            initializationValue,\n            initializationValue\n          );\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n              0,\n              0\n          );\n\n          "+l+"\n        } else if ("+(3===u)+") {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            initializationValue\n          );\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n            0\n          );\n\n          "+l+"\n        }\n        setOutput(sumValue);\n      }\n    "};for(var fX=0,dX=[Nq,Sq,MG,LG,zG,PG,VG,jG,HG,qG,JG,ZG,QG,$G,tj,ej,nj,oj,ij,lj,cj,pj,dj,xj,wj,Tj,Ej,Dj,Oj,iG,Vj,Qj,$j,Kj,tH,nH,eH,aH,iH,sH,pH,hH,dH,xH,wH,gH,NH,SH,CH,EH,RH,DH,OH,LH,PH,VH,HH,KH,YH,JH,$H,eq,tq,rq,iq,oq,sq,rG,uq,Bj,lq,cq,pq,uG,hq,fq,dq,gq,vq,yq,bq,xq,Cq,Aq,Rq,_q,Oq,Mq,Eq,Lq,zq,Pq,Vq,Gq,Qq,wG,eK,nK,aK,oK,Nj,uK,pK,hK,vK,yK,pG,bK,wK,Sj,qq,kK,IK,NK,NG,CK,RK,DK,_K,LK,PK,BK,WK,UK,jK,HK,qK,KK,YK,JK,bj,Zq,ZK,QK,$K,eX,tX,nX,rX,aX,oX,Yq,DG,uX,{kernelName:"Tanh",backendName:"webgl",kernelFunc:lX},{kernelName:"Tile",backendName:"webgl",kernelFunc:pX},{kernelName:"TopK",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=r.k,o=r.sorted,s=n.texData.get(a.dataId).values,u=OU(s,a.shape,a.dtype,i,o),l=u[0],c=u[1];return[n.makeTensorInfo(l.shape,l.dtype,l.values),n.makeTensorInfo(c.shape,c.dtype,c.values)]}},_G,{kernelName:"Unique",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.attrs,r=e.backend,a=n.axis,i=t.x;TV(i,"unique"),console.warn("WARNING: ","UI might be locked temporarily as data is being downloaded");var o=r.readSync(i.dataId),s=LU(o,a,i.shape,i.dtype),u=s.outputValues,l=s.outputShape,c=s.indices;return[r.makeTensorInfo(l,i.dtype,u),r.makeTensorInfo([c.length],"int32",c)]}},{kernelName:"Unpack",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.value,i=r.axis;i<0&&(i+=a.shape.length);for(var o=a,s=o.shape.length,u=a.shape[i],l=new Array(s-1),c=0,p=0;p<s;p++)p!==i&&(l[c++]=o.shape[p]);var h=[],f=new Array(s).fill(0),d=o.shape.slice();d[i]=1;for(var m=new Array(u),v=0;v<m.length;v++){f[i]=v;var g=yj({inputs:{x:o},backend:n,attrs:{begin:f,size:d}}),y=kG({inputs:{x:g},backend:n,attrs:{shape:l}});m[v]=y,h.push(g)}return h.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),m}},{kernelName:"UnsortedSegmentSum",backendName:"webgl",kernelFunc:function(e){var t=e.inputs,n=e.backend,r=e.attrs,a=t.x,i=t.segmentIds,o=r.numSegments,s=a.shape.length,u=[],l=0,c=Ik([l],s),p=a;null!=c&&(p=FG({inputs:{x:a},backend:n,attrs:{perm:c}}),u.push(p),l=Tk(1,s)[0]);var h=ST(p.shape,l,o),f=fv([p.shape[l]]),d=kG({inputs:{x:p},backend:n,attrs:{shape:[-1,f]}});u.push(d);var m=kG({inputs:{x:function e(t,r,a,i,o){var s=t.shape[0],l=t.shape[1],c=IT(l,o),p=new hX({windowSize:c,inSize:l,batchSize:s,numSegments:o},r),h=n.compileAndRun(p,[t,a],i);if(u.push(h),h.shape[1]===o)return h;var f=xK({backend:n,attrs:{start:0,stop:o,step:1,dtype:"float32"}}),d=pX({inputs:{x:f},backend:n,attrs:{reps:[l/c]}});return u.push(f),u.push(d),e(h,r,d,i,o)}(d,"unsortedSegmentSum",i,Vg(a.dtype),o)},backend:n,attrs:{shape:h}}),v=m;if(null!=c){u.push(m);var g=Sk(c);v=FG({inputs:{x:v},backend:n,attrs:{perm:g}})}return u.forEach((function(e){return n.disposeIntermediateTensorInfo(e)})),v}},cK];fX<dX.length;fX++){fg(dX[fX])}var mX={"tfjs-core":"2.8.1","tfjs-backend-cpu":"2.8.1","tfjs-backend-webgl":"2.8.1","tfjs-data":"2.8.1","tfjs-layers":"2.8.1","tfjs-converter":"2.8.1",tfjs:"2.8.1"};e.Abs="Abs",e.Acos="Acos",e.Acosh="Acosh",e.AdadeltaOptimizer=KS,e.AdagradOptimizer=XS,e.AdamOptimizer=YS,e.AdamaxOptimizer=JS,e.Add=Zv,e.AddN="AddN",e.All="All",e.Any="Any",e.ArgMax="ArgMax",e.ArgMin="ArgMin",e.Asin="Asin",e.Asinh="Asinh",e.Atan="Atan",e.Atan2="Atan2",e.Atanh="Atanh",e.AvgPool="AvgPool",e.AvgPool3D="AvgPool3D",e.AvgPool3DGrad="AvgPool3DGrad",e.AvgPoolGrad="AvgPoolGrad",e.BatchMatMul="BatchMatMul",e.BatchToSpaceND="BatchToSpaceND",e.Bincount="Bincount",e.BroadcastTo="BroadcastTo",e.Callback=q_,e.CallbackList=tA,e.Cast="Cast",e.Ceil="Ceil",e.ClipByValue="ClipByValue",e.Complex="Complex",e.ComplexAbs="ComplexAbs",e.Concat="Concat",e.Conv2D="Conv2D",e.Conv2DBackpropFilter="Conv2DBackpropFilter",e.Conv2DBackpropInput="Conv2DBackpropInput",e.Conv3D="Conv3D",e.Conv3DBackpropFilterV2="Conv3DBackpropFilterV2",e.Conv3DBackpropInputV2="Conv3DBackpropInputV2",e.Cos=Qv,e.Cosh="Cosh",e.CropAndResize="CropAndResize",e.Cumsum="Cumsum",e.CustomCallback=aA,e.DataStorage=nv,e.DenseBincount="DenseBincount",e.DepthToSpace="DepthToSpace",e.DepthwiseConv2dNative="DepthwiseConv2dNative",e.DepthwiseConv2dNativeBackpropFilter="DepthwiseConv2dNativeBackpropFilter",e.DepthwiseConv2dNativeBackpropInput="DepthwiseConv2dNativeBackpropInput",e.Diag="Diag",e.Dilation2D="Dilation2D",e.Dilation2DBackpropFilter="Dilation2DBackpropFilter",e.Dilation2DBackpropInput="Dilation2DBackpropInput",e.EarlyStopping=Y_,e.Elu=$v,e.EluGrad="EluGrad",e.Environment=qv,e.Equal="Equal",e.Erf=eg,e.Exp=tg,e.ExpandDims="ExpandDims",e.Expm1="Expm1",e.FFT="FFT",e.Fill="Fill",e.FlipLeftRight="FlipLeftRight",e.Floor="Floor",e.FloorDiv="FloorDiv",e.FromPixels="FromPixels",e.FusedBatchNorm="FusedBatchNorm",e.FusedConv2D="FusedConv2D",e.FusedDepthwiseConv2D="FusedDepthwiseConv2D",e.GatherNd="GatherNd",e.GatherV2="GatherV2",e.GraphModel=pM,e.Greater="Greater",e.GreaterEqual="GreaterEqual",e.History=rA,e.IFFT="IFFT",e.Identity="Identity",e.Imag="Imag",e.InputSpec=UR,e.IsFinite="IsFinite",e.IsInf="IsInf",e.IsNan="IsNan",e.KernelBackend=rv,e.LRN="LRN",e.LRNGrad="LRNGrad",e.LayerVariable=BR,e.LayersModel=kD,e.LeakyRelu="LeakyRelu",e.Less="Less",e.LessEqual="LessEqual",e.LinSpace="LinSpace",e.Log=ng,e.Log1p="Log1p",e.LogSoftmax="LogSoftmax",e.LogicalAnd="LogicalAnd",e.LogicalNot="LogicalNot",e.LogicalOr="LogicalOr",e.Max="Max",e.MaxPool="MaxPool",e.MaxPool3D="MaxPool3D",e.MaxPool3DGrad="MaxPool3DGrad",e.MaxPoolGrad="MaxPoolGrad",e.MaxPoolWithArgmax="MaxPoolWithArgmax",e.Maximum="Maximum",e.Mean="Mean",e.Min="Min",e.Minimum="Minimum",e.MirrorPad="MirrorPad",e.Mod=rg,e.MomentumOptimizer=QS,e.Multinomial="Multinomial",e.Multiply="Multiply",e.Neg="Neg",e.NonMaxSuppressionV3="NonMaxSuppressionV3",e.NonMaxSuppressionV4="NonMaxSuppressionV4",e.NonMaxSuppressionV5="NonMaxSuppressionV5",e.NotEqual="NotEqual",e.OP_SCOPE_SUFFIX="__op",e.OneHot="OneHot",e.OnesLike="OnesLike",e.Optimizer=qS,e.Pack="Pack",e.PadV2="PadV2",e.Pool="Pool",e.Pow=ag,e.Prelu="Prelu",e.Prod="Prod",e.RMSPropOptimizer=$S,e.RNN=EF,e.Range="Range",e.Real="Real",e.RealDiv="RealDiv",e.Reciprocal="Reciprocal",e.Relu="Relu",e.Relu6="Relu6",e.Reshape="Reshape",e.ResizeBilinear="ResizeBilinear",e.ResizeBilinearGrad="ResizeBilinearGrad",e.ResizeNearestNeighbor="ResizeNearestNeighbor",e.ResizeNearestNeighborGrad="ResizeNearestNeighborGrad",e.Reverse="Reverse",e.RotateWithOffset="RotateWithOffset",e.Round="Round",e.Rsqrt="Rsqrt",e.SGDOptimizer=ZS,e.ScatterNd="ScatterNd",e.Select="Select",e.Selu="Selu",e.Sequential=RD,e.Sigmoid="Sigmoid",e.Sign="Sign",e.Sin=ig,e.Sinh="Sinh",e.Slice="Slice",e.Softmax="Softmax",e.Softplus="Softplus",e.SpaceToBatchND="SpaceToBatchND",e.SparseToDense="SparseToDense",e.SplitV="SplitV",e.Sqrt="Sqrt",e.Square="Square",e.SquaredDifference="SquaredDifference",e.Step="Step",e.StridedSlice="StridedSlice",e.Sub=og,e.Sum="Sum",e.SymbolicTensor=GR,e.Tan=sg,e.Tanh="Tanh",e.Tensor=Fg,e.TensorBuffer=Rg,e.Tile="Tile",e.TopK="TopK",e.Transpose="Transpose",e.Unique="Unique",e.Unpack="Unpack",e.UnsortedSegmentSum="UnsortedSegmentSum",e.Variable=Pg,e.ZerosLike="ZerosLike",e._FusedMatMul="_FusedMatMul",e.abs=Ix,e.acos=Sx,e.acosh=Tx,e.add=xx,e.addN=Cx,e.addStrict=NI,e.all=Ex,e.any=Rx,e.argMax=Ax,e.argMin=Dx,e.asin=Fx,e.asinh=_x,e.atan=Ox,e.atan2=Mx,e.atanh=Lx,e.avgPool=Zx,e.avgPool3d=Qx,e.backend=bx,e.backend_util=RT,e.basicLSTMCell=rw,e.batchNorm=iw,e.batchNorm2d=ow,e.batchNorm3d=sw,e.batchNorm4d=uw,e.batchToSpaceND=aw,e.bincount=lw,e.booleanMaskAsync=vI,e.broadcastTo=cw,e.browser=Fb,e.buffer=nb,e.callbacks=Q_,e.cast=rb,e.ceil=pw,e.clipByValue=hw,e.clone=ab,e.complex=sy,e.concat=$x,e.concat1d=fw,e.concat2d=dw,e.concat3d=mw,e.concat4d=vw,e.constraints=IE,e.conv1d=yw,e.conv2d=gw,e.conv2dTranspose=xw,e.conv3d=ww,e.conv3dTranspose=Nw,e.copyRegisteredKernels=function(e,t){hg(e).forEach((function(e){fg(Object.assign({},e,{backendName:t}))}))},e.cos=Iw,e.cosh=Sw,e.cosineWindow=BI,e.cumsum=Tw,e.customGrad=ck,e.data=bL,e.denseBincount=Cw,e.deprecationWarn=px,e.depthToSpace=Ew,e.depthwiseConv2d=Rw,e.deregisterOp=function(e){delete $_[e]},e.device_util=ey,e.diag=Aw,e.dilation2d=Dw,e.disableDeprecationWarnings=function(){Xv().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.")},e.dispose=mx,e.disposeVariables=function(){Jg.disposeVariables()},e.div=kx,e.divNoNan=Pw,e.divStrict=II,e.dot=Bw,e.dropout=zI,e.elu=Ww,e.enableDebugMode=function(){Xv().set("DEBUG",!0)},e.enableProdMode=function(){Xv().set("PROD",!0)},e.enclosingPowerOfTwo=PI,e.engine=hx,e.env=Xv,e.equal=Mw,e.equalStrict=gI,e.erf=Vw,e.exp=Uw,e.expandDims=Gw,e.expm1=jw,e.eye=qw,e.fft=qN,e.fill=Kw,e.findBackend=function(e){return Jg.findBackend(e)},e.findBackendFactory=function(e){return Jg.findBackendFactory(e)},e.floor=Xw,e.floorDiv=wx,e.fused=QI,e.gather=Yw,e.gatherND=LI,e.gather_util=Ob,e.getBackend=function(){return Jg.backendName},e.getGradient=pg,e.getKernel=cg,e.getKernelsForBackend=hg,e.grad=function(e){return lv(Ov(e),(function(){return"The f passed in grad(f) must be a function"})),function(t,n){var r=ay(t,"x","tf.grad",null),a=null!=n?ay(n,"dy","tf.grad"):null;return Jg.tidy((function(){var t=Jg.gradients((function(){return e(r)}),[r],a),n=t.value,i=t.grads;return null!=a&&cv(n.shape,a.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),pk(i),i[0]}))}},e.grads=function(e){return lv(Ov(e),(function(){return"The f passed in grads(f) must be a function"})),function(t,n){lv(Array.isArray(t),(function(){return"The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s"}));var r=iy(t,"args","tf.grads",null),a=null!=n?ay(n,"dy","tf.grads"):null;return Jg.tidy((function(){var t=Jg.gradients((function(){return e.apply(void 0,r)}),r,a),n=t.value,i=t.grads;return null!=a&&cv(n.shape,a.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),pk(i),i}))}},e.greater=Jw,e.greaterEqual=Zw,e.greaterEqualStrict=yI,e.greaterStrict=bI,e.ifft=KN,e.imag=Qw,e.image=GS,e.inTopKAsync=VI,e.initializers=RR,e.input=AD,e.io=Nb,e.irfft=XN,e.isFinite=$w,e.isInf=ek,e.isNaN=tk,e.keep=vx,e.kernel_impls=AT,e.layers=U_,e.leakyRelu=nk,e.less=rk,e.lessEqual=ak,e.lessEqualStrict=xI,e.lessStrict=wI,e.linalg=jS,e.linspace=ik,e.loadGraphModel=function(e,t){return hM.apply(this,arguments)},e.loadLayersModel=function(e,t){return null==t&&(t={}),function(e,t){return SD.apply(this,arguments)}(e,t)},e.localResponseNormalization=ok,e.log=sk,e.log1p=uk,e.logSigmoid=dk,e.logSoftmax=yk,e.logSumExp=Ck,e.logicalAnd=Ek,e.logicalNot=Rk,e.logicalOr=Ak,e.logicalXor=Dk,e.losses=HS,e.matMul=Ib,e.math=Eb,e.max=mk,e.maxPool=Fk,e.maxPool3d=_k,e.maxPoolWithArgmax=Ok,e.maximum=Mk,e.maximumStrict=SI,e.mean=Lk,e.memory=fx,e.metrics=G_,e.min=zk,e.minimum=Pk,e.minimumStrict=TI,e.mirrorPad=Bk,e.mod=Wk,e.modStrict=CI,e.model=function(e){return new kD(e)},e.models=j_,e.moments=Uk,e.movingAverage=_I,e.mul=Nx,e.mulStrict=EI,e.multiRNNCell=Gk,e.multinomial=jk,e.neg=hk,e.nextFrame=rT,e.norm=FI,e.notEqual=Hk,e.notEqualStrict=kI,e.oneHot=Sb,e.ones=Kk,e.onesLike=Xk,e.op=oy,e.outerProduct=Yk,e.pad=Jk,e.pad1d=Zk,e.pad2d=Qk,e.pad3d=$k,e.pad4d=eN,e.pool=nN,e.pow=rN,e.powStrict=RI,e.prelu=aN,e.print=ib,e.prod=iN,e.profile=function(e){return Jg.profile(e)},e.rand=oN,e.randomGamma=yN,e.randomNormal=bN,e.randomUniform=xN,e.range=wN,e.ready=function(){return Jg.ready()},e.real=kN,e.reciprocal=NN,e.registerBackend=yx,e.registerCallbackConstructor=function(e,t){oA.registerCallbackConstructor(e,t)},e.registerGradient=dg,e.registerKernel=fg,e.registerOp=function(e,t){var n={tfOpName:e,category:"custom",inputs:[],attrs:[],customExecutor:t};$_[e]=n},e.regularizers=H_,e.relu=IN,e.relu6=SN,e.removeBackend=function(e){Jg.removeBackend(e)},e.reshape=Jx,e.reverse=TN,e.reverse1d=CN,e.reverse2d=EN,e.reverse3d=RN,e.reverse4d=AN,e.rfft=JN,e.round=DN,e.rsqrt=FN,e.scalar=_N,e.scatterND=OI,e.scatter_util=Pb,e.selu=ON,e.separableConv2d=MN,e.sequential=function(e){return new RD(e)},e.serialization=ix,e.setBackend=gx,e.setPlatform=function(e,t){Xv().setPlatform(e,t)},e.setdiff1dAsync=zN,e.sigmoid=ew,e.sign=PN,e.signal=US,e.sin=BN,e.sinh=WN,e.slice=tw,e.slice1d=VN,e.slice2d=UN,e.slice3d=GN,e.slice4d=jN,e.slice_util=tx,e.softmax=HN,e.softplus=fk,e.spaceToBatchND=tN,e.sparseToDense=MI,e.spectral=VS,e.split=YN,e.sqrt=ZN,e.square=Vk,e.squaredDifference=QN,e.squaredDifferenceStrict=AI,e.squeeze=$N,e.stack=eI,e.step=tI,e.stridedSlice=nI,e.sub=vk,e.subStrict=DI,e.sum=gk,e.sumOutType=Vg,e.tan=rI,e.tanh=nw,e.tensor=ly,e.tensor1d=aI,e.tensor2d=iI,e.tensor3d=Rb,e.tensor4d=function(e,t,n){if(pv(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");var r=ny(e,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return uy(e,t,r,n)},e.tensor5d=function(e,t,n){if(pv(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");var r=ny(e,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return uy(e,t,r,n)},e.tensor6d=function(e,t,n){if(pv(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");var r=ny(e,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return uy(e,t=t||r,r,n)},e.tensor_util=qg,e.test_util=cx,e.tidy=dx,e.tile=Hw,e.time=function(e){return Jg.time(e)},e.topk=oI,e.train=tT,e.transpose=Tb,e.truncatedNormal=sI,e.unique=uI,e.unregisterGradient=function(e){if(!lg.has(e))throw new Error("The gradient '"+e+"' for backend is not registered");lg.delete(e)},e.unregisterKernel=function(e,t){var n=mg(e,t);if(!ug.has(n))throw new Error("The kernel '"+e+"' for backend '"+t+"' is not registered");ug.delete(n)},e.unsortedSegmentSum=lI,e.unstack=cI,e.upcastType=Wg,e.util=kg,e.valueAndGrad=function(e){return lv(Ov(e),(function(){return"The f passed in valueAndGrad(f) must be a function"})),function(t,n){lv(t instanceof Fg,(function(){return"The x passed in valueAndGrad(f)(x) must be a tensor"})),lv(null==n||n instanceof Fg,(function(){return"The dy passed in valueAndGrad(f)(x, dy) must be a tensor"}));var r=Jg.gradients((function(){return e(t)}),[t],n),a=r.grads,i=r.value;return pk(a),{grad:a[0],value:i}}},e.valueAndGrads=function(e){return lv(Ov(e),(function(){return"The f passed in valueAndGrads(f) must be a function"})),function(t,n){lv(Array.isArray(t)&&t.every((function(e){return e instanceof Fg})),(function(){return"The args passed in valueAndGrads(f)(args) must be array of tensors"})),lv(null==n||n instanceof Fg,(function(){return"The dy passed in valueAndGrads(f)(args, dy) must be a tensor"}));var r=Jg.gradients((function(){return e.apply(void 0,t)}),t,n);return null!=n&&cv(r.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),pk(r.grads),r}},e.variable=pI,e.variableGrads=lk,e.version=mX,e.version_converter="2.8.1",e.version_core="2.8.1",e.version_layers="2.8.1",e.where=Lw,e.whereAsync=dI,e.zeros=qk,e.zerosLike=zw,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=tf.min.js.map
